Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sleep Calculator

807600Sep 18 2007 — edited Sep 18 2007
This tinme I'm supposed to create a calculator that displays how long you have been alive (in days) and how long you have slept for assuming that you sleep 8hrs a night, there are 30 days in each month, and 365 days in a year.

I've come up with this much but I'm not quite sure where to go from here.

import java.util.Scanner;

/**
* This application determines the amouth of time that you spent sleeping
* Zachary
*/
public class Sleep {

public static void main (String[] args){
double year; //Birth Year
double month; //Birth month
double day; //Birth day
double todaysyear; //Current Year
double todaysmonth; //Current month
double todaysday; //Current day
Scanner input = new Scanner(System.in);

System.out.print("Enter your birthdate:");
System.out.print("Year: ");
year = input.nextInt();
System.out.print("Month: ");
month = input.nextInt();
System.out.print("Day: ");
day = input.nextInt();
input.close();

System.out.print("Enter today's date:");
System.out.print("Year: ");
todaysyear = input.nextInt();
System.out.print("Month: ");
todaysmonth = input.nextInt();
System.out.print("Day: ");
todaysday = input.nextInt();
input.close();
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2007
Added on Sep 18 2007
5 comments
497 views