Advertisement
veronikaaa86

ThreeBrothers

Oct 1st, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P02_ThreeBrothers {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double bro1 = Double.parseDouble(scanner.nextLine());
  8.         double bro2 = Double.parseDouble(scanner.nextLine());
  9.         double bro3 = Double.parseDouble(scanner.nextLine());
  10.         double father = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double allTime = 1/(1/bro1+1/bro2+1/bro3);
  13.         double allTimePlusRest = allTime+(allTime*0.15);
  14.         double timeLeft = father-allTimePlusRest;
  15.  
  16.  
  17.         if (timeLeft>0) {
  18.             timeLeft = father-allTimePlusRest;
  19.             System.out.printf("Cleaning time: %.2f\n", allTimePlusRest);
  20.             System.out.printf("Yes, there is a surprise - time left -> %.0f hours.", Math.floor(timeLeft));
  21.         } else  {
  22.             timeLeft = allTimePlusRest-father;
  23.             System.out.printf("Cleaning time: %.2f\n", allTimePlusRest);
  24.             System.out.printf("No, there isn't a surprise - shortage of time -> %.0f hours.", Math.ceil(timeLeft));
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement