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