Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SleepyTomCat {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int holidays = Integer.parseInt(console.nextLine());
- double playOnHolidays=holidays*127;
- double playOnWorkingdays=(365 - holidays)*63;
- double timeToSleep = 30000;
- double timeToPlay= playOnHolidays + playOnWorkingdays;
- if(timeToPlay>timeToSleep){
- double totalMin = timeToSleep - timeToPlay;
- double totalHours = Math.abs(totalMin / 60);
- double minutes = Math.abs(totalMin % 60);
- System.out.println("Tom will run away");
- System.out.printf("%d hours and %d minutes more for play", (int)totalHours, (int)minutes);
- }else{
- double totalMin = timeToPlay - timeToSleep;
- double totalHours = Math.abs(totalMin / 60);
- double minutes = Math.abs(totalMin % 60);
- System.out.println("Tom sleeps well");
- System.out.printf("%d hours and %d minutes less for play", (int)totalHours, (int)minutes);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment