Advertisement
stoyanoff

02. Sleepy Tom Cat

Jun 9th, 2020
1,342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SleepyTomCat_02 {
  4.     public static void main(String[] args) {
  5.         Scanner myScan = new Scanner(System.in);
  6.  
  7.         // init the constants
  8.         int gameTimeWorkingDay = 63;
  9.         int gameTimeRestDay = 127;
  10.         int daysOfTheYear = 365;
  11.         int targetGamePerYear = 30000;
  12.  
  13.         // init the days off per year
  14.         int holidayDays = Integer.parseInt(myScan.nextLine());
  15.  
  16.         // calculating how many game minutes per year
  17.  
  18.         int gameMinutesPerYear = ((daysOfTheYear - holidayDays) * gameTimeWorkingDay) + gameTimeRestDay * holidayDays;
  19.  
  20.         if (gameMinutesPerYear <= targetGamePerYear) {
  21.  
  22.             System.out.println("Tom sleeps well");
  23.  
  24.             int differenceInPlayTime = targetGamePerYear - gameMinutesPerYear;
  25.             int hours = differenceInPlayTime / 60;
  26.             int minutes = differenceInPlayTime % 60;
  27.             System.out.printf("%d hours and %d minutes less for play",hours,minutes);
  28.         } else {
  29.             System.out.println("Tom will run away");
  30.             int differenceInPlayTime = gameMinutesPerYear - targetGamePerYear;
  31.             int hours = differenceInPlayTime / 60;
  32.             int minutes = differenceInPlayTime % 60;
  33.             System.out.printf("%d hours and %d minutes more for play",hours,minutes);
  34.         }
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement