Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PipesInPool {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int v = Integer.parseInt(scan.nextLine());
  7. int p1 = Integer.parseInt(scan.nextLine());
  8. int p2 = Integer.parseInt(scan.nextLine());
  9. double h = Double.parseDouble(scan.nextLine());
  10. double pi1 = p1 * h;
  11. double pi2 = p2 * h;
  12. double fill = pi1 + pi2;
  13. char per = '%';
  14. if (fill > v) {
  15. double overflow = fill - v;
  16. System.out.printf("For %.2f hours the pool overflows with %.2f liters.", h , overflow);
  17. } else {
  18. double percentFull = (fill / v) * 100;
  19. double percentP1 = (pi1 / fill) * 100;
  20. double percentP2 = (pi2 / fill) * 100;
  21. System.out.printf("The pool is %.2f%c full. Pipe 1: %.2f%c. Pipe 2: %.2f%c.", percentFull, per, percentP1, per, percentP2, per);
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement