Advertisement
dakata450

Untitled

Jun 13th, 2022
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package gg;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PipesInPool {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. int vPool = Integer.parseInt(scanner.nextLine());
  9. int tube1 = Integer.parseInt(scanner.nextLine());
  10. int tube2 = Integer.parseInt(scanner.nextLine());
  11. double hours = Double.parseDouble(scanner.nextLine());
  12. double pipe1 = tube1 * hours;
  13. double pipe2 = tube2 * hours;
  14.  
  15. double fullDebit = pipe1 + pipe2;
  16. double poolPercent = (fullDebit / 1000) * 100;
  17. double pipe1Percent = (pipe1 / fullDebit) * 100;
  18. double pipe2Percent = (pipe2 / fullDebit) * 100;
  19. if (fullDebit > vPool){
  20. System.out.printf("For %.2f hours the pool overflows with %.2f liters.", hours, fullDebit - vPool);
  21. }else {
  22. System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", poolPercent, pipe1Percent, pipe2Percent);
  23. }
  24.  
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement