Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class p18_Pipes_in_pool {
- 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 fullness = p1 * h + p2 * h;
- double x = fullness * 100 / v;
- double y = p1 * h / fullness * 100;
- double z = p2 * h / fullness * 100;
- if (fullness > v) {
- DecimalFormat df = new DecimalFormat("0.##");
- System.out.printf("For %s hours the pool overflows with %d liters.", df.format(h), (int) (fullness - v));
- } else {
- System.out.printf("The pool is %s%% full. Pipe 1: %s%%. Pipe 2: %s%%.", (int) x, (int) y, (int) z);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment