Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E01PipesInPool {
- 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 waterAll = (P1 * H) + (P2 * H);
- if (waterAll <= V) {
- System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.",
- (waterAll/V) * 100,
- ((P1 * H) / waterAll) * 100,
- ((P2 * H) / waterAll) * 100);
- } else {
- System.out.printf("For %f hours the pool overflows with %f liters.", H, (waterAll - V));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment