Advertisement
damesova

Pool Pipes - Java

Jan 25th, 2019
1,476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 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 hours = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double water = p1*hours + p2*hours;
  13.  
  14.         if (water<=v){
  15.             System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.",
  16.                 Math.floor(water/v*100),
  17.                 Math.floor(p1*hours/water*100),
  18.                 Math.floor(p2*hours/water*100));
  19.         }else{
  20.             System.out.printf("For %f hours the pool overflows with %f liters.", hours, water - v);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement