Advertisement
GabrielHr00

08. Lunch Break

Mar 17th, 2024
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package _02_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 episodeTime = 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.         double freeTime = breakTime - lunchTime - restTime;
  15.  
  16.         if (freeTime >= episodeTime) {
  17.             System.out.printf("You have enough time to watch %s and left with %.0f minutes free time.",
  18.                     seriesName, Math.ceil(freeTime - episodeTime));
  19.         } else {
  20.             System.out.printf("You don't have enough time to watch %s, you need %.0f more minutes.",
  21.                     seriesName, Math.ceil(episodeTime - freeTime));
  22.         }
  23.  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement