Question: Part III: Picking up the Pieces (25 points) Write a function capsule volume () that computes the volume of material required to create a rounded,

 Part III: Picking up the Pieces (25 points) Write a function
capsule volume () that computes the volume of material required to create

Part III: Picking up the Pieces (25 points) Write a function capsule volume () that computes the volume of material required to create a rounded, cylin- drical metal capsule with walls of a provided thickness. The function takes three arguments that provide the dimensions of the capsule: 1. length: the length of the capsule in cm 2. radius: the radius of the capsule in cm 3. thickness: the thickness of the capsule's walls in cm length thickness Note that each end of the capsule is hemispherical. The radius of each hemisphere is the same as the radius of the cylindrical part of the capsule. As shown in the figure above, the cavity inside the capsule is also cylindrical with hemispherical ends. The thickness of the wall determines the radius of the cavity. (Hint: can you derive a formula to get the radius of the cavity) You will find the following formulas helpful Volume of a sphere of radius Volume of a cylinder of radius and height = "h In your code, you must use math.pl to perform the computations, or else it is likely your code will generate incorrect results Your de must also do some basic error checking. Specifically, if the length of the capsule is less than or equal to two times the radius, return the floating point value-1.0 to indicate invalid parameters. Or, if any of the three argument is or negative, return -1.0. Examples: Function Arguments Return value 8.0, 3.0, 0.001 0.15075246926393504 8.0, 3.0, 1.0 111.00294042683936 (3.0, 8.0, 1.5 -1.0 3.0, 1.0, 0.5 6.021385919380436 23.0, 7.0, 5.0 -1.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!