Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ThreeBrothers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double timeFirstBro = Double.parseDouble(scanner.nextLine());
- double timeSecBro = Double.parseDouble(scanner.nextLine());
- double timeTirthBro = Double.parseDouble(scanner.nextLine());
- double timeFather = Double.parseDouble(scanner.nextLine());
- double breakTime = 0.15;
- double time = 0;
- double timeWithBreak = 0;
- double timeLeft = 0;
- time = 1 / (1 / timeFirstBro + 1 / timeSecBro + 1 / timeTirthBro);
- timeWithBreak = (time * breakTime) + time;
- timeLeft = timeFather - timeWithBreak;
- if (timeLeft > 0) {
- System.out.printf("Cleaning time: %.2f%nYes, there is a surprise - time left -> %.0f hours.",
- timeWithBreak, Math.floor(timeLeft));
- } else {
- System.out.printf("Cleaning time: %.2f%nNo, there isn't a surprise - shortage of time -> %.0f hours.",
- timeWithBreak, Math.abs(Math.floor(timeLeft)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement