Advertisement
Angel_Kalinkov

PBE-17September2017-ThreeBrothers_AngelKalinkov

Feb 14th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ThreeBrothers {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double brother1 = Double.parseDouble(scanner.nextLine());
  8.         double brother2 = Double.parseDouble(scanner.nextLine());
  9.         double brother3 = Double.parseDouble(scanner.nextLine());
  10.         double fishtime = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double cleaningTime = 1 / (1 / brother1 + 1 / brother2 + 1 / brother3);
  13.         double totalTime = cleaningTime + cleaningTime * 0.15;
  14.         double timeDifference = Math.abs(fishtime - totalTime);
  15.         String output = "";
  16.  
  17.         if (fishtime > totalTime) {
  18.             output = String.format("Yes, there is a surprise - time left -> %.0f hours.%n", Math.floor(timeDifference));
  19.         } else {
  20.             output = String.format("No, there isn't a surprise - shortage of time -> %.0f hours.%n", Math.ceil(timeDifference));
  21.         }
  22.         System.out.printf("Cleaning time: %.2f%n", totalTime);
  23.         System.out.println(output);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement