Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class num {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int V = Integer.parseInt(console.nextLine());
- int P1 = Integer.parseInt(console.nextLine());
- int P2 = Integer.parseInt(console.nextLine());
- double h = Double.parseDouble(console.nextLine());
- if (V >= 1 && V <= 10000) {
- if (P1 > 0 && P1 <= 5000) {
- if (P2 > 0 && P2 <= 5000) {
- if (h > 0 && h < 25) {
- int sum = (int) ((P1 + P2) * h);
- int percentv = (int) (100 * sum / V); // х% от общото количество
- int percentp1 = (int) (P1 * h * 100 / sum); // %р1 общото количество = количеството на р1 за h часа
- int percentp2 = (int) (P2 * h * 100 / sum);
- if (sum > V) {
- int overflow = (int) (sum - V);
- System.out.print("For " + h + " hours the pool overflows with " + overflow + " liters.");
- } else {
- //System.out.printf("The pool is %d% full. Pipe 1: %s%. Pipe 2: %m%" + percentv + percentp1 + percentp2); // ?
- System.out.println("The pool is " + percentv + "% full. Pipe 1: " + percentp1 + "%. Pipe 2: " + percentp2 + "%.");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement