Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PipesPool {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int volumePullLiters = Integer.parseInt(scanner.nextLine());
- int p1PerHour = Integer.parseInt(scanner.nextLine());
- int p2PerHour = Integer.parseInt(scanner.nextLine());
- double hoursMiss = Double.parseDouble(scanner.nextLine());
- double p1Capacited = p1PerHour * hoursMiss;
- double p2Capacited = p2PerHour * hoursMiss;
- double p1PlusP2 = p1Capacited + p2Capacited;
- if (p1PlusP2 < volumePullLiters) {
- p1Capacited = p1Capacited / p1PlusP2 * 100;
- p2Capacited = p2Capacited / p1PlusP2 * 100;
- p1PlusP2 = p1PlusP2 / volumePullLiters * 100;
- char per = '%';
- System.out.printf("The pool is %.2f%c full. Pipe 1: %.2f%c. Pipe 2: %.2f%c.", p1PlusP2, per, p1Capacited, per, p2Capacited, per);
- } else {
- p1PlusP2 = p1PlusP2 - volumePullLiters;
- System.out.printf("For %.2f hours the pool overflows with %.2f liters.", hoursMiss, p1PlusP2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement