Advertisement
Spocoman

08. Lunch Break

Aug 24th, 2024
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LunchBreak {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String serialName = scanner.nextLine();
  7.         int serialTime = Integer.parseInt(scanner.nextLine());
  8.         int breakTime = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double neededTime = breakTime / 8.0 + breakTime / 4.0 + serialTime;
  11.  
  12.         if (neededTime <= breakTime) {
  13.             System.out.printf("You have enough time to watch %s and left with %.0f minutes free time.", serialName, breakTime - Math.floor(neededTime));
  14.         } else {
  15.             System.out.printf("You don't have enough time to watch %s, you need %.0f more minutes.", serialName, Math.ceil(neededTime) - breakTime);
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement