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 scan = new Scanner(System.in);
- int v = Integer.parseInt(scan.nextLine());
- int p1 = Integer.parseInt(scan.nextLine());
- int p2 = Integer.parseInt(scan.nextLine());
- double h = Double.parseDouble(scan.nextLine());
- double pi1 = p1 * h;
- double pi2 = p2 * h;
- double fill = pi1 + pi2;
- char per = '%';
- if (fill > v) {
- double overflow = fill - v;
- System.out.printf("For %.2f hours the pool overflows with %.2f liters.", h , overflow);
- } else {
- double percentFull = (fill / v) * 100;
- double percentP1 = (pi1 / fill) * 100;
- double percentP2 = (pi2 / fill) * 100;
- System.out.printf("The pool is %.2f%c full. Pipe 1: %.2f%c. Pipe 2: %.2f%c.", percentFull, per, percentP1, per, percentP2, per);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement