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