Advertisement
veronikaaa86

Three Brothers

Jan 23rd, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Demo2 {
  5.     public static void main(String[] args) {
  6.         Scanner scan = new Scanner(System.in);
  7.  
  8.         double BigBrother = Double.parseDouble(scan.nextLine());
  9.         double MiddleBrother = Double.parseDouble(scan.nextLine());
  10.         double SmallBrother =Double.parseDouble(scan.nextLine());
  11.         double FatherTime = Double.parseDouble(scan.nextLine());
  12.  
  13.         double CleanigTime=1/(1/BigBrother+1/MiddleBrother+1/SmallBrother);
  14.         double RestTime = CleanigTime * 0.15;
  15.         double AllTime = RestTime + CleanigTime;
  16.  
  17.         double RemainingTime = Math.abs(AllTime-FatherTime);
  18.  
  19.  
  20.         if(AllTime <= FatherTime){
  21.             System.out.printf("Cleaning time: %.2f%n",AllTime);
  22.             System.out.printf("Yes, there is a surprise - time left -> %.0f hours.", Math.floor(RemainingTime));
  23.         }else{
  24.             System.out.printf("Cleaning time: %.2f%n",AllTime);
  25.             System.out.printf("No, there isn't a surprise - shortage of time -> %.0f hours.", Math.ceil(RemainingTime));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement