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 v = Integer.parseInt(scanner.nextLine());
- int p1 = Integer.parseInt(scanner.nextLine());
- int p2 = Integer.parseInt(scanner.nextLine());
- double h = Double.parseDouble(scanner.nextLine());
- double filled = p1*h + p2*h;
- if (filled > v) {
- double overflow = filled - v;
- System.out.printf("For %.1f hours the pool overflows with %.1f liters.", h, overflow);
- } else {
- double percentall = Math.floor((filled/v)*100);
- double percentP1 = Math.floor(((p1*h)/filled)*100);
- double percentP2 = Math.floor(((p2*h)/filled)*100);
- System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", percentall, percentP1, percentP2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement