Advertisement
Valantina

LunchBreak

Jun 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P02_LunchBreak {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String serial = scan.nextLine();
  8.         int serialLength = Integer.parseInt(scan.nextLine());
  9.         int restTime = Integer.parseInt(scan.nextLine());
  10.  
  11.         double timeToEat = restTime / 8.0;
  12.         double timeToRest = restTime / 4.0;
  13.  
  14.         double timeLeft = restTime - timeToEat - timeToRest;
  15.  
  16.         if (timeLeft >= serialLength) {
  17.             double freeTime = Math.ceil(timeLeft - serialLength);
  18.             System.out.println(String.format("You have enough time to watch %s and left with %.0f minutes free time.",
  19.                     serial, freeTime));
  20.         } else {
  21.             double timeNeed = Math.ceil(serialLength - timeLeft);
  22.             System.out.println(String.format("You don't have enough time to watch %s, you need %.0f more minutes.",
  23.                     serial, timeNeed));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement