Advertisement
MladenKarachanov

LunchBreak

Nov 27th, 2023
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package firstStepsInCoding.MoreExercises;
  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 nameFilm=scanner.nextLine();
  9.         int episode=Integer.parseInt(scanner.nextLine());
  10.         int durationRest=Integer.parseInt(scanner.nextLine());
  11.         double time=0;
  12.         double lunch=durationRest*0.125;
  13.         double rest=durationRest*0.25;
  14.         time=durationRest-lunch-rest;
  15.  
  16.         double diff=Math.abs(episode-time);
  17.         if (time>=episode){
  18.  
  19.             System.out.printf("You have enough time to watch %s and left with %.0f minutes free time.",nameFilm,diff);
  20.  
  21.         }else{
  22.             System.out.printf("You don't have enough time to watch %s, you need %.0f more minutes.",nameFilm,diff);
  23.         }
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement