CMIS 102
Homework
Due: 21 April
Create a program that calculates the areas and volumes of various 3D
geometric objects: cylinders, cones, cubes and spheres.
The formula for the area of a cylinder is:
(two times pi times radius times height plus two times pi times radius squared)
the formula for the area of a sphere is:
(four times pi times radius squared)
formula for area of a cone:
(pi times radius times square root of radius squared plus height squared
plus pi times radius squared)
formula for area of a cube:
(six times side length squared) Let the side length be "height"
Volume of sphere:
(four-thirds times pi times radius cubed)
Volume of cylinder:
(pi times radius squared times height)
Volume of cone:
(one-third times pi times radius squared times height)
Volume of a cube:
(height cubed)
Input from the user the radius and height of the solids. Use the same
values for all the solids (input it only once). You are writing one
program that does all 8 calculations.
Display the results tabularly like the following:
------------------------------------------------
radius xx
height xx
Solid Area Volume
----- ----- ------
cone xx.xx xx.xx
sphere x.xx x.xx
cylinder xx.xx x.xx
cube x.xx x.xx
where the x's are the actual values. Display 2 digits of precision
after the decimal point.
Turn in a printout of the source code and a diskette with the
program.
Groups of up to three people are allowed but not required.