Advertisement
mswi12

PipesInPool

Aug 30th, 2017
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.Math;
  3. public class PipesInPool {
  4.     public static void main(String []args){
  5.         Scanner scanner = new Scanner(System.in);
  6.         int volumePool = Integer.parseInt(scanner.nextLine());
  7.         int pipeOne = Integer.parseInt(scanner.nextLine());
  8.         int pipeTwo = Integer.parseInt(scanner.nextLine());
  9.         Double hours = Double.parseDouble(scanner.nextLine());
  10.         Double volumeFull = (pipeOne + pipeTwo) * hours;
  11.         Double volumeOverFull = (volumeFull - volumePool);
  12.         Double pipePoolnPersent = (volumeFull / volumePool) * 100;
  13.         Double pipeOneInPersent = ((pipeOne * hours) / volumeFull) * 100;
  14.         Double pipeTwoInPersent = ((pipeTwo * hours) / volumeFull) * 100;
  15.  
  16.         if (volumeFull <= volumePool){
  17.             System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%", Math.floor(pipePoolnPersent), Math.floor(pipeOneInPersent), Math.floor(pipeTwoInPersent));
  18.         } else {
  19.  
  20.             System.out.printf("For %f hours the pool overflows with %f liters.", hours, volumeOverFull);
  21.  
  22.         }
  23.  
  24.  
  25.  
  26.  
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement