Advertisement
SUni2020

SleepyTomCat

Mar 25th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.Math;
  3. public class SleepyTomCat {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int holidays = Integer.parseInt(scanner.nextLine());
  7. int work = 365 - holidays;
  8. int totalplaydays = work * 63 + holidays * 127;
  9. int totalMins = 30000 - totalplaydays;
  10. int hours = Math.abs(totalMins / 60);
  11. int mins = Math.abs(totalMins % 60);
  12.  
  13. if (30000 < totalplaydays)
  14. {
  15.  
  16. System.out.println("Tom will run away");
  17. System.out.printf(" %d hours and %d minutes more for play", hours, mins);
  18.  
  19. }
  20. else
  21. {
  22. System.out.println("Tom sleeps well");
  23. System.out.printf(" %d hours and %d minutes less for play", hours, mins);
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement