desislava_topuzakova

Untitled

Jan 23rd, 2022
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E01PipesInPool {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int V = Integer.parseInt(scanner.nextLine());
  7. int P1 = Integer.parseInt(scanner.nextLine());
  8. int P2 = Integer.parseInt(scanner.nextLine());
  9. double H = Double.parseDouble(scanner.nextLine());
  10.  
  11. double waterAll = (P1 * H) + (P2 * H);
  12.  
  13. if (waterAll <= V) {
  14. System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.",
  15. (waterAll/V) * 100,
  16. ((P1 * H) / waterAll) * 100,
  17. ((P2 * H) / waterAll) * 100);
  18.  
  19. } else {
  20. System.out.printf("For %f hours the pool overflows with %f liters.", H, (waterAll - V));
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment