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