Advertisement
GabrielHr00

08. Lunch Break

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