Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PipesPool {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int volumePullLiters = Integer.parseInt(scanner.nextLine());
  8. int p1PerHour = Integer.parseInt(scanner.nextLine());
  9. int p2PerHour = Integer.parseInt(scanner.nextLine());
  10. double hoursMiss = Double.parseDouble(scanner.nextLine());
  11.  
  12. double p1Capacited = p1PerHour * hoursMiss;
  13. double p2Capacited = p2PerHour * hoursMiss;
  14. double p1PlusP2 = p1Capacited + p2Capacited;
  15.  
  16. if (p1PlusP2 < volumePullLiters) {
  17. p1Capacited = p1Capacited / p1PlusP2 * 100;
  18. p2Capacited = p2Capacited / p1PlusP2 * 100;
  19. p1PlusP2 = p1PlusP2 / volumePullLiters * 100;
  20. char per = '%';
  21. System.out.printf("The pool is %.2f%c full. Pipe 1: %.2f%c. Pipe 2: %.2f%c.", p1PlusP2, per, p1Capacited, per, p2Capacited, per);
  22. } else {
  23. p1PlusP2 = p1PlusP2 - volumePullLiters;
  24. System.out.printf("For %.2f hours the pool overflows with %.2f liters.", hoursMiss, p1PlusP2);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement