myrdok123

08. Lunch Break

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