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 brother1 = Double.parseDouble(scanner.nextLine());
- double brother2 = Double.parseDouble(scanner.nextLine());
- double brother3 = Double.parseDouble(scanner.nextLine());
- double fishtime = Double.parseDouble(scanner.nextLine());
- double cleaningTime = 1 / (1 / brother1 + 1 / brother2 + 1 / brother3);
- double totalTime = cleaningTime + cleaningTime * 0.15;
- double timeDifference = Math.abs(fishtime - totalTime);
- String output = "";
- if (fishtime > totalTime) {
- output = String.format("Yes, there is a surprise - time left -> %.0f hours.%n", Math.floor(timeDifference));
- } else {
- output = String.format("No, there isn't a surprise - shortage of time -> %.0f hours.%n", Math.ceil(timeDifference));
- }
- System.out.printf("Cleaning time: %.2f%n", totalTime);
- System.out.println(output);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement