Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Pipes{
- 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 pipe1Full = pipe1 * hours;
- double pipe2Full = pipe2 * hours;
- double totalPipes = pipe1Full + pipe2Full;
- double fullPool = (totalPipes / volume) * 100.0;
- double prPipe1 =(pipe1Full / totalPipes) * 100.0;
- double prPipe2 = (pipe2Full / totalPipes) * 100.0;
- double overWater = totalPipes-volume;
- if (totalPipes <= volume) {
- System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", fullPool, prPipe1 , prPipe2);
- }
- else {
- System.out.printf("For %s hours the pool overflows with %.2f liters.",hours , overWater );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement