Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package W02ConditionalStatements.Exercises;
- import java.util.Scanner;
- public class P08LunchBreak {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String serialName = scanner.nextLine();
- int duration = Integer.parseInt(scanner.nextLine());
- int lunchBreak = Integer.parseInt(scanner.nextLine());
- //Пресмятаме колко време ще обядваме и колко време ще ни е почивка
- double timeForEat = lunchBreak / 8.0;
- double timeForRest = lunchBreak / 4.0;
- //Пресмятаме времето за гледане на сериала
- double timeForWatch = lunchBreak - timeForEat - timeForRest;
- //Проверяваме дали оставащото време е достатъчно, за да изгледаме 1 серия от сериала
- double diff = Math.ceil(Math.abs(timeForWatch - duration));
- if (timeForWatch >= duration){
- System.out.printf("You have enough time to watch %s and left with %.0f minutes free time.",
- serialName, diff);
- }else {
- System.out.printf("You don't have enough time to watch %s, you need %.0f more minutes.",
- serialName, diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement