Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sleep;
- import java.util.Scanner;
- public class Sleep {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int year,month,day,tyear,tmonth,tday,yyear,ymonth,yday,alive,sleep=0;
- System.out.println("Please enter your birthday,use the numerical for the month too.");
- System.out.print("Birth year:");
- year = input.nextInt();
- System.out.print("Birth month:");
- month = input.nextInt();
- System.out.print("Birth date:");
- day = input.nextInt();
- System.out.print("Today's year:");
- tyear = input.nextInt();
- System.out.print("Today's month:");
- tmonth = input.nextInt();
- System.out.print("Today's date:");
- tday = input.nextInt();
- yyear = 365*(tyear-year);
- ymonth = 30*(tmonth-month);
- yday = (tday-tmonth);
- alive = (yyear+ymonth+yday);
- sleep = (alive*8);
- System.out.print("You have been alive for "+alive);
- System.out.println(" days.");
- System.out.print("You have slept for "+sleep);
- System.out.print(" hours.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement