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 bro1 = Double.parseDouble(scanner.nextLine());
- double bro2 = Double.parseDouble(scanner.nextLine());
- double bro3 = Double.parseDouble(scanner.nextLine());
- double fishingTime = Double.parseDouble(scanner.nextLine());
- double cleaningTime = 1 / (1 /bro1 + 1/bro2 + 1/bro3);
- double timewithBreak = cleaningTime + cleaningTime * 15 / 100;
- double timeLeft = fishingTime - timewithBreak;
- System.out.printf("Cleaning time: %.2f\n", timewithBreak);
- if(timeLeft > 0) {
- System.out.printf("Yes, there is a surprise - time left -> %.0f hours.", Math.floor(timeLeft));
- }else {
- timeLeft = Math.abs(timeLeft);
- System.out.printf("No, there isn't a surprise - shortage of time -> %.0f hours.", Math.ceil(timeLeft));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement