Advertisement
Spocoman

01. Pipes In Pool

Aug 24th, 2024
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PipesInPool {
  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.         double poolV = (pipe1 + pipe2) * hours;
  12.         double poolP = poolV / volume;
  13.  
  14.         if (volume >= poolV) {
  15.             System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.",
  16.                     poolP * 100, pipe1 / poolV * hours * 100, pipe2 / poolV * hours * 100);
  17.         } else {
  18.             System.out.printf("For %f hours the pool overflows with %.2f liters.", hours, poolV - volume);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement