BubaLazi

p02_SleepyTomCat

Mar 17th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SleepyTomCat {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         int holidays = Integer.parseInt(console.nextLine());
  8.  
  9.         double playOnHolidays=holidays*127;
  10.         double playOnWorkingdays=(365 - holidays)*63;
  11.  
  12.         double timeToSleep = 30000;
  13.         double timeToPlay= playOnHolidays + playOnWorkingdays;
  14.  
  15.         if(timeToPlay>timeToSleep){
  16.             double totalMin = timeToSleep - timeToPlay;
  17.             double totalHours = Math.abs(totalMin / 60);
  18.             double minutes = Math.abs(totalMin % 60);
  19.             System.out.println("Tom will run away");
  20.             System.out.printf("%d hours and %d minutes more for play", (int)totalHours, (int)minutes);
  21.         }else{
  22.             double totalMin = timeToPlay - timeToSleep;
  23.             double totalHours = Math.abs(totalMin / 60);
  24.             double minutes = Math.abs(totalMin % 60);
  25.             System.out.println("Tom sleeps well");
  26.             System.out.printf("%d hours and %d minutes less for play", (int)totalHours, (int)minutes);
  27.         }
  28.  
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment