Fill 'Er Up
This is a simple project mainly for practice running
and submitting a C program.
Write a program which requests and reads three double values. The first
are the the height and diameter of a cylindrical bucket, given in
centimeters. The third is a (constant) fill rate for the bucket, given
as milliliters per second. The program then reports the amount
of time needed to fill the bucket with water at the stated rate.
The calculation is straightforward. The volume of the bucket is
v=h×πr2
where
r is the radius of the base (half the diameter).
The volume,
v, is in cubic centimeters. Since a cubic centimeter
is a milliliter, you can
divide
v by the flow rate to get the time for that volume to
flow into the bucket.
For instance:
[user@home asst1]$ ./fill
Enter bucket height (cm): 10
Enter diameter (cm): 4
Enter fill rate (ml/s): 20
Bucket of diameter 4 cm and 10 cm tall filling at 20 ml/s
will fill in 6.28318 seconds.
[user@home asst1]$ ./fill
Enter bucket height (cm): 60
Enter diameter (cm): 40
Enter fill rate (ml/s): 12
Bucket of diameter 40 cm and 60 cm tall filling at 12 ml/s
will fill in 6283.18 seconds.
[user@home asst1]$ ./fill
Enter bucket height (cm): 12.6
Enter diameter (cm): 5.25
Enter fill rate (ml/s): 35.88
Bucket of diameter 5.25 cm and 12.6 cm tall filling at 35.88 ml/s
will fill in 7.60197 seconds.
[user@home asst1]$ ./fill
Enter bucket height (cm): 65
Enter diameter (cm): 45
Enter fill rate (ml/s): 250
Bucket of diameter 45 cm and 65 cm tall filling at 250 ml/s
will fill in 413.512 seconds.
[user@home asst1]$ ./fill
Enter bucket height (cm): 150
Enter diameter (cm): 30
Enter fill rate (ml/s): 900
Bucket of diameter 30 cm and 150 cm tall filling at 900 ml/s
will fill in 117.81 seconds.
When your program works and looks nice,
submit over the web
here.