Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SleepyTomCat_02 {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- // init the constants
- int gameTimeWorkingDay = 63;
- int gameTimeRestDay = 127;
- int daysOfTheYear = 365;
- int targetGamePerYear = 30000;
- // init the days off per year
- int holidayDays = Integer.parseInt(myScan.nextLine());
- // calculating how many game minutes per year
- int gameMinutesPerYear = ((daysOfTheYear - holidayDays) * gameTimeWorkingDay) + gameTimeRestDay * holidayDays;
- if (gameMinutesPerYear <= targetGamePerYear) {
- System.out.println("Tom sleeps well");
- int differenceInPlayTime = targetGamePerYear - gameMinutesPerYear;
- int hours = differenceInPlayTime / 60;
- int minutes = differenceInPlayTime % 60;
- System.out.printf("%d hours and %d minutes less for play",hours,minutes);
- } else {
- System.out.println("Tom will run away");
- int differenceInPlayTime = gameMinutesPerYear - targetGamePerYear;
- int hours = differenceInPlayTime / 60;
- int minutes = differenceInPlayTime % 60;
- System.out.printf("%d hours and %d minutes more for play",hours,minutes);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement