Advertisement
Anamaria93

Untitled

Mar 2nd, 2020
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pool {
  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 waterP1 = p1 * h;
  12. double waterP2 = p2 * h;
  13. double TotalFill = waterP1 + waterP2;
  14. double percentOccupancy = TotalFill / v * 100; //exprimat in procent
  15. double percentWater1 = waterP1 / TotalFill * 100;
  16. double percentWater2 = waterP2 / TotalFill * 100;
  17. double overFlow = TotalFill - v;
  18.  
  19. if (TotalFill == v)
  20. { overFlow = 0;
  21. System.out.printf("Overflow = %.0f. ", overFlow);
  22. System.out.printf("The pool is %.0f%% full.", percentOccupancy);}
  23.  
  24.  
  25. else if (TotalFill > v) {
  26.  
  27. System.out.printf("For %.2f hours the pool overflows with %.2f liters.", h, overFlow);
  28.  
  29. } else if (TotalFill < v)
  30. System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", percentOccupancy, percentWater1, percentWater2);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement