Advertisement
JackHoughton00

Sleep

Feb 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. package sleep;
  2. import java.util.Scanner;
  3.  
  4. public class Sleep {
  5.  
  6. public static void main(String[] args) {
  7. Scanner input = new Scanner(System.in);
  8. int year,month,day,tyear,tmonth,tday,yyear,ymonth,yday,alive,sleep=0;
  9. System.out.println("Please enter your birthday,use the numerical for the month too.");
  10. System.out.print("Birth year:");
  11. year = input.nextInt();
  12. System.out.print("Birth month:");
  13. month = input.nextInt();
  14. System.out.print("Birth date:");
  15. day = input.nextInt();
  16. System.out.print("Today's year:");
  17. tyear = input.nextInt();
  18. System.out.print("Today's month:");
  19. tmonth = input.nextInt();
  20. System.out.print("Today's date:");
  21. tday = input.nextInt();
  22.  
  23. yyear = 365*(tyear-year);
  24. ymonth = 30*(tmonth-month);
  25. yday = (tday-tmonth);
  26. alive = (yyear+ymonth+yday);
  27.  
  28. sleep = (alive*8);
  29.  
  30.  
  31.  
  32. System.out.print("You have been alive for "+alive);
  33. System.out.println(" days.");
  34. System.out.print("You have slept for "+sleep);
  35. System.out.print(" hours.");
  36.  
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement