Skip to content
← Back to Community
Homework; pipes in a swimming pool
Profile icon
MariaStoyanova1

Hello,everyone!
I need some guideness ...
I have homework and the task is,as written:
"A pool has two pipes that fill it and volume V. Each pipe has a certain flow rate (liter of water passing through one pipe per hour). The worker runs the pipes at the same time and goes out for N hours. Write down a program that takes the condition of the pool at the moment the worker returns.
Input data:
Four rows are read from the console:
The first row contains the number V - volume of the pool in liters - an integer in the range [1 ... 10000].
The second row contains the number P1 - the flow of the first pipe per hour - an integer in the range [1 ... 5000].
The third row contains the number P2 - the second pipe flow per hour - an integer in the range [1 ... 5000].
The fourth row contains the number H - the hours in which the worker is absent - a floating point in the range [1.0 ... 24.00]

Output data:
Print one of two possible states on the console:

How far the pool has been filled and how each pipe has contributed to the percentage. At all percentages, take only the whole portion (ie, round off). "Pipe 1: [y]% Pipe 2: [z]%." If the pool is overflowing - how many liters it has overflowed for a given time, a floating point number. "For [x] hours, the pool overflows with [y] liters."

I have to use Math.floor() and System.out.printf() in Java

Here is a link towards the task:
https://java-book.softuni.bg/chapter-03-simple-conditions-exam-problems.html

And my code by far:
https://repl.it/@MariaStoyanova1/Homework-pipes-in-a-swimming-pool

Voters
Profile icon
AlexMcBride
Profile icon
MariaStoyanova1