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