Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pipes{
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int volume = Integer.parseInt(scanner.nextLine());
  7. int pipe1 = Integer.parseInt(scanner.nextLine());
  8. int pipe2 = Integer.parseInt(scanner.nextLine());
  9. double hours = Double.parseDouble(scanner.nextLine());
  10.  
  11.  
  12. double pipe1Full = pipe1 * hours;
  13. double pipe2Full = pipe2 * hours;
  14.  
  15. double totalPipes = pipe1Full + pipe2Full;
  16.  
  17. double fullPool = (totalPipes / volume) * 100.0;
  18. double prPipe1 =(pipe1Full / totalPipes) * 100.0;
  19. double prPipe2 = (pipe2Full / totalPipes) * 100.0;
  20.  
  21. double overWater = totalPipes-volume;
  22.  
  23. if (totalPipes <= volume) {
  24.  
  25. System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", fullPool, prPipe1 , prPipe2);
  26. }
  27. else {
  28.  
  29. System.out.printf("For %s hours the pool overflows with %.2f liters.",hours , overWater );
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement