Advertisement
desislava_topuzakova

ThreeBrothers

Jan 26th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ThreeBrothers3 {
  4.     public static void main(String[] agrs) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double A = Double.parseDouble(scanner.nextLine());
  7.         double B = Double.parseDouble(scanner.nextLine());
  8.         double C = Double.parseDouble(scanner.nextLine());
  9.         double fishingTime = Double.parseDouble(scanner.nextLine());
  10.  
  11.         double cleaningTime = 1 / (1 / A + 1 / B + 1 / C);
  12.         double rest = (cleaningTime * 0.15) + cleaningTime;
  13.         double allCleaningTime = fishingTime - rest;
  14.  
  15.         if (allCleaningTime > 0) {
  16.             System.out.printf("Cleaning time: %.2f %n", rest);
  17.             System.out.printf("Yes, there is a surprise - time left -> %d hours.", (int) (Math.floor(fishingTime - rest)));
  18.         } else {
  19.             System.out.printf("Cleaning time: %.2f %n", rest);
  20.             System.out.printf("No, there isn't a surprise - shortage of time -> %d hours.", (int) (Math.ceil(rest - fishingTime)));
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement