Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MoreEx_CatTom {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // READ:
- // resting days
- //KNOW
- // when owner is working they play 63 min each working day
- // when owner is resting they play 127 min each rest day
- // LOOK FOR
- // Calculate working days in the year if a year = 365 days
- // calculate work days * 63 min + rest days * 127min - total paly time in min
- // Tom can max play 30 000 min per year, calc difference 30 000 - total play time in min
- // convert min into HH & min
- int restDays = Integer.parseInt(scanner.nextLine());
- int workDays = 365 - restDays;
- int minInRestDays = restDays * 127;
- int minInWorksDays = workDays* 63;
- int totalMinPlayYear = minInRestDays + minInWorksDays;
- if (totalMinPlayYear >= 30000) {
- int diff1 = totalMinPlayYear - 30000;
- int convertHou = diff1 / 60;
- int convertMin = diff1 % 60;
- System.out.println("Tom will run away");
- System.out.printf("%02d hours and %02d minutes more for play", convertHou, convertMin);
- }
- else {
- int diff2 = 30000 - totalMinPlayYear;
- int convertHou = diff2 / 60;
- int convertMin = diff2 % 60;
- System.out.println("Tom sleeps well");
- System.out.printf("%02d hours and %02d minutes less for play", convertHou, convertMin);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement