Advertisement
Guest User

ThreeBrothers

a guest
Oct 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 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 bro1 = Double.parseDouble(scanner.nextLine());
  8. double bro2 = Double.parseDouble(scanner.nextLine());
  9. double bro3 = Double.parseDouble(scanner.nextLine());
  10. double fishingTime = Double.parseDouble(scanner.nextLine());
  11.  
  12. double cleaningTime = 1 / (1 /bro1 + 1/bro2 + 1/bro3);
  13. double timewithBreak = cleaningTime + cleaningTime * 15 / 100;
  14. double timeLeft = fishingTime - timewithBreak;
  15.  
  16. System.out.printf("Cleaning time: %.2f\n", timewithBreak);
  17.  
  18. if(timeLeft > 0) {
  19. System.out.printf("Yes, there is a surprise - time left -> %.0f hours.", Math.floor(timeLeft));
  20. }else {
  21. timeLeft = Math.abs(timeLeft);
  22. System.out.printf("No, there isn't a surprise - shortage of time -> %.0f hours.", Math.ceil(timeLeft));
  23. }
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement