Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ThreeBrothers {
  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. double d = Double.parseDouble(scanner.nextLine());
  12.  
  13. double cleaningTime = 1/(1/a + 1/b + 1/c);
  14. double timeAndBreak = cleaningTime + (cleaningTime*0.15);
  15. double hoursLeft = d - timeAndBreak;
  16.  
  17. System.out.printf("Cleaning time: %.2f%n", timeAndBreak);
  18.  
  19. if (hoursLeft > 0) {
  20. System.out.printf("Yes, there is a surprise - time left -> %.0f hours.", Math.floor(hoursLeft));
  21. } else if (hoursLeft <= 0){
  22. System.out.printf("No, there isn't a surprise - shortage of time -> %.0f hours.", Math.abs(Math.floor(hoursLeft)));
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement