Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int v = scanner.nextInt();
- int p1 = scanner.nextInt();
- int p2 = scanner.nextInt();
- double h = scanner.nextDouble();
- double pipe1 = h * p1;
- double pipe2 = h * p2;
- double pipe1Percent = pipe1 / v;
- double pipe2Percent = pipe2 / v;
- if (pipe1 + pipe2 > v) {
- System.out.printf("For %.2f hours the pool overflows with %.2f litres.",h,pipe1+pipe2-v);
- } else {
- System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.",(pipe1Percent + pipe2Percent) * 100, pipe1Percent * 100,pipe2Percent * 100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement