Advertisement
psi_mmobile

Untitled

Apr 17th, 2022
971
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int v = scanner.nextInt();
  5.         int p1 = scanner.nextInt();
  6.         int p2 = scanner.nextInt();
  7.         double h = scanner.nextDouble();
  8.        
  9.         double pipe1 = h * p1;
  10.         double pipe2 = h * p2;
  11.        
  12.         double pipe1Percent = pipe1 / v;
  13.         double pipe2Percent = pipe2 / v;
  14.        
  15.         if (pipe1 + pipe2 > v) {
  16.             System.out.printf("For %.2f hours the pool overflows with %.2f litres.",h,pipe1+pipe2-v);
  17.         } else {
  18.             System.out.printf("The pool is %.2f%%  full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.",(pipe1Percent + pipe2Percent) * 100, pipe1Percent * 100,pipe2Percent * 100);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement