Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_26_March_2016 - created by borkins on 2017-05-14.
- */
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class _02_PoolPipes
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- DecimalFormat decFormat = new DecimalFormat("0.##");
- int volumePool = Integer.parseInt(console.nextLine());
- int flowPipe1 = Integer.parseInt(console.nextLine());
- int flowPipe2 = Integer.parseInt(console.nextLine());
- double hours = Double.parseDouble(console.nextLine());
- double totalLiters = (flowPipe1 + flowPipe2) * hours;
- if (volumePool >= (int) totalLiters)
- {
- double totalPipe1 = flowPipe1 * hours * 100 / totalLiters;
- double totalPipe2 = flowPipe2 * hours * 100 / totalLiters;
- System.out.printf("The pool is %d%% full. Pipe 1: %d%%. Pipe 2: %d%%.",
- (int) (totalLiters * 100 / volumePool),
- (int) totalPipe1, (int) totalPipe2);
- } else {
- System.out.printf("For %s hours the pool overflows with %s liters.",
- decFormat.format(hours),
- decFormat.format(totalLiters - volumePool));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement