Advertisement
veronikaaa86

Brothers

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