galinyotsev123

ProgBasics03Conditional-Statements-Y06ThreeBrothers

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