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);
- 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 waterP1 = p1 * h;
- double waterP2 = p2 * h;
- double TotalFill = waterP1 + waterP2;
- double percentOccupancy = TotalFill / v * 100; //exprimat in procent
- double percentWater1 = waterP1 / TotalFill * 100;
- double percentWater2 = waterP2 / TotalFill * 100;
- double overFlow = TotalFill - v;
- if (TotalFill == v)
- { overFlow = 0;
- System.out.printf("Overflow = %.0f. ", overFlow);
- System.out.printf("The pool is %.0f%% full.", percentOccupancy);}
- else if (TotalFill > v) {
- System.out.printf("For %.2f hours the pool overflows with %.2f liters.", h, overFlow);
- } else if (TotalFill < v)
- System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", percentOccupancy, percentWater1, percentWater2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement