Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Y06ThreeBrothers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double firstBroCleaningTime = Double.parseDouble(scanner.nextLine());
- double secondBroCleaningTime = Double.parseDouble(scanner.nextLine());
- double thirdBroCleaningTime = Double.parseDouble(scanner.nextLine());
- double fatherMissingTime = Double.parseDouble(scanner.nextLine());
- double cleaningTimeAllBros = 1 / (1 / firstBroCleaningTime + 1 / secondBroCleaningTime + 1 / thirdBroCleaningTime);
- double cleaningTimeAllBrosWithRest = cleaningTimeAllBros + cleaningTimeAllBros * 15 / 100.0;
- System.out.printf("Cleaning time: %.2f\n", cleaningTimeAllBrosWithRest);
- if (fatherMissingTime < cleaningTimeAllBrosWithRest){
- System.out.printf("No, there isn't a surprise - " +
- "shortage of time -> %.0f hours.",
- Math.ceil(cleaningTimeAllBrosWithRest - fatherMissingTime));
- } else {
- System.out.printf("Yes, there is a surprise - " +
- "time left -> %.0f hours.",
- Math.floor(fatherMissingTime - cleaningTimeAllBrosWithRest));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment