Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exam18december;
- import java.util.Scanner;
- public class trubi {
- 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 p1Result = p1 * h;
- double p2Result = p2 * h;
- double totalResult = p1Result + p2Result;
- if (totalResult <= v) {
- double all = Math.floor(totalResult / v * 100);
- double p1Percent = Math.floor(p1Result / totalResult * 100);
- double p2Percent = Math.floor(p2Result / totalResult * 100);
- System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", all, p1Percent, p2Percent);
- } else {
- double all = totalResult - v;
- if (h % 1 == 0) {
- System.out.printf("For %.0f hours the pool overflows with %.1f liters.", h, all);
- } else {
- System.out.printf("For %.1f hours the pool overflows with %.1f liters.", h, all);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement