Advertisement
manchev90

Untitled

Sep 19th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 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.  
  7.         int volume = Integer.parseInt(scanner.nextLine());
  8.         int pipe1 = Integer.parseInt(scanner.nextLine());
  9.         int pipe2 = Integer.parseInt(scanner.nextLine());
  10.         double hours = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double pipe1Full = pipe1 * hours;
  13.         double pipe2Full = pipe2 * hours;
  14.         double totalPipes = pipe1Full + pipe2Full;
  15.         double fullPool = (totalPipes / volume) * 100;
  16.         double prPipe1 =(pipe1Full / totalPipes) * 100;
  17.         double prPipe2 = (pipe2Full / totalPipes) * 100;
  18.         double overWater = fullPool-volume;
  19.  
  20.         if (fullPool <= volume) {
  21.  
  22.             System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", fullPool, prPipe1 , prPipe2);
  23.         }
  24.         else {
  25.             System.out.printf("For %.2f hours the pool overflows with %.2f liters.", hours , overWater );
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement