Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class test3 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.         int v = Integer.parseInt(in.nextLine());
  8.         int p1 = Integer.parseInt(in.nextLine());
  9.         int p2 = Integer.parseInt(in.nextLine());
  10.         double h = Double.parseDouble(in.nextLine());
  11.         in.close();
  12.         double p1all = p1 * h;
  13.         double p2all = p2 * h;
  14.         if (p1all + p2all < v) {
  15.             System.out.printf("The pool is %.2f full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", (p1all + p2all) * 100 / v,
  16.                     p1all * 100 / (p1all + p2all), p2all * 100 / (p1all + p2all));
  17.         } else {
  18.             System.out.printf("For %.2f hours the pool overflows with %.2f liters.", h, p1all + p2all - v);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement