Advertisement
martyz

Pool Pipes - Softuni

Aug 4th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PoolPipes {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int v = Integer.parseInt(scanner.nextLine());
  8.         int p1 = Integer.parseInt(scanner.nextLine());
  9.         int p2 = Integer.parseInt(scanner.nextLine());
  10.         double h = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double sump1=p1*h;
  13.         double sump2=p2*h;
  14.         Integer n3 = 0;
  15.         Double overflow = 0d;
  16.  
  17.         Double pump1End = ((sump1))/(sump1+sump2)*100;
  18.         Integer n1 = pump1End.intValue();
  19.         Double pump2End = (sump2)/(sump1+sump2)*100;
  20.         Integer n2 = pump2End.intValue();
  21.  
  22.         if ((sump1+sump2) <= v ){
  23.             overflow  = Math.abs((sump1+sump2)/v*100);
  24.             n3 = overflow.intValue();
  25.         } else {
  26.             overflow = ((sump1 + sump2) - v);
  27.         }
  28.  
  29.  
  30.         if ((sump1+sump2) <= v) {
  31.             System.out.println("The pool is " + n3 +  "% full. Pipe 1: " + n1 + "%. Pipe 2: " + n2 + "%.");
  32.  
  33.         } else {
  34.             System.out.println("For " + h + " hours the pool overflows with " + overflow + " liters.");
  35.         }
  36.  
  37.     }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement