Advertisement
Spocoman

02. Sleepy Tom Cat

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