Advertisement
Ivakis

Three brothers

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