Advertisement
tenachev

Three Brothers

Apr 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 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 timeFirstBro = Double.parseDouble(scanner.nextLine());
  8.         double timeSecBro = Double.parseDouble(scanner.nextLine());
  9.         double timeTirthBro = Double.parseDouble(scanner.nextLine());
  10.         double timeFather = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double breakTime = 0.15;
  13.         double time = 0;
  14.         double timeWithBreak = 0;
  15.         double timeLeft = 0;
  16.  
  17.         time = 1 / (1 / timeFirstBro + 1 / timeSecBro + 1 / timeTirthBro);
  18.         timeWithBreak = (time * breakTime) + time;
  19.         timeLeft = timeFather - timeWithBreak;
  20.  
  21.         if (timeLeft > 0) {
  22.             System.out.printf("Cleaning time: %.2f%nYes, there is a surprise - time left -> %.0f hours.",
  23.                     timeWithBreak, Math.floor(timeLeft));
  24.         } else {
  25.             System.out.printf("Cleaning time: %.2f%nNo, there isn't a surprise - shortage of time -> %.0f hours.",
  26.                     timeWithBreak, Math.abs(Math.floor(timeLeft)));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement