Advertisement
myrdok123

P08_LunchBreak

Jan 15th, 2023
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. package L02_Exercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P08_LunchBreak {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.  
  10.         String serialName = scanner.nextLine();
  11.         int duration = Integer.parseInt(scanner.nextLine());
  12.         int lunchBreak = Integer.parseInt(scanner.nextLine());
  13.  
  14.  
  15.         double timeForEat = lunchBreak / 8.0;
  16.         double timeForRest = lunchBreak / 4.0;
  17.  
  18.         double timeForWatch = lunchBreak - timeForEat - timeForRest;
  19.  
  20.         if (timeForWatch >= duration){
  21.             System.out.printf("You have enough time to watch %s and left with %.0f minutes free time."
  22.             , serialName, Math.ceil(timeForWatch - duration));
  23.         }else {
  24.             System.out.printf("You don't have enough time to watch %s, you need %.0f more minutes."
  25.                     , serialName, Math.ceil(duration - timeForWatch));
  26.         }
  27.  
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement