Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PoolPipes {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int v = Integer.parseInt(scanner.nextLine());
- int p1 = Integer.parseInt(scanner.nextLine());
- int p2 = Integer.parseInt(scanner.nextLine());
- double h = Double.parseDouble(scanner.nextLine());
- double sump1=p1*h;
- double sump2=p2*h;
- Integer n3 = 0;
- Double overflow = 0d;
- Double pump1End = ((sump1))/(sump1+sump2)*100;
- Integer n1 = pump1End.intValue();
- Double pump2End = (sump2)/(sump1+sump2)*100;
- Integer n2 = pump2End.intValue();
- if ((sump1+sump2) <= v ){
- overflow = Math.abs((sump1+sump2)/v*100);
- n3 = overflow.intValue();
- } else {
- overflow = ((sump1 + sump2) - v);
- }
- if ((sump1+sump2) <= v) {
- System.out.println("The pool is " + n3 + "% full. Pipe 1: " + n1 + "%. Pipe 2: " + n2 + "%.");
- } else {
- System.out.println("For " + h + " hours the pool overflows with " + overflow + " liters.");
- }
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement