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