Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.utilities;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class VegFruit {
- 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 N = Double.parseDouble(scanner.nextLine());
- double sum = (N * P1) + (N * P2);
- if (sum <= V) {
- int x = (int) ((sum / V) * 100);
- int y = (int) (((N * P1) / sum) * 100);
- int z = (int) (((N * P2) / sum )* 100);
- System.out.printf("The pool is %d%% full. Pipe 1: %d%%. Pipe 2: %d%%.", x, y, z);
- } else if (sum > V) {
- double q = sum - V;
- System.out.printf("For %s hours the pool overflows with %s liters.",
- new DecimalFormat("#.##").format(N), new DecimalFormat("#.##").format(q));
- }
- }
- }
Add Comment
Please, Sign In to add comment