Advertisement
IvaAnd

CatTom

Feb 19th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MoreEx_CatTom {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. // READ:
  9. // resting days
  10.  
  11. //KNOW
  12. // when owner is working they play 63 min each working day
  13. // when owner is resting they play 127 min each rest day
  14.  
  15. // LOOK FOR
  16. // Calculate working days in the year if a year = 365 days
  17. // calculate work days * 63 min + rest days * 127min - total paly time in min
  18. // Tom can max play 30 000 min per year, calc difference 30 000 - total play time in min
  19. // convert min into HH & min
  20.  
  21. int restDays = Integer.parseInt(scanner.nextLine());
  22. int workDays = 365 - restDays;
  23. int minInRestDays = restDays * 127;
  24. int minInWorksDays = workDays* 63;
  25. int totalMinPlayYear = minInRestDays + minInWorksDays;
  26.  
  27.  
  28. if (totalMinPlayYear >= 30000) {
  29.  
  30. int diff1 = totalMinPlayYear - 30000;
  31. int convertHou = diff1 / 60;
  32. int convertMin = diff1 % 60;
  33. System.out.println("Tom will run away");
  34. System.out.printf("%02d hours and %02d minutes more for play", convertHou, convertMin);
  35. }
  36.  
  37. else {
  38. int diff2 = 30000 - totalMinPlayYear;
  39. int convertHou = diff2 / 60;
  40. int convertMin = diff2 % 60;
  41. System.out.println("Tom sleeps well");
  42. System.out.printf("%02d hours and %02d minutes less for play", convertHou, convertMin);
  43.  
  44. }
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement