Advertisement
veronikaaa86

08. Lunch Break

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