Question
Write a C++ program which requests and reads three double values. The first are the the diameter and height of a cylindrical bucket, given in
Write a C++ program which requests and reads three double values. The first are the the diameter and height 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=hr2
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): 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started