CIS 22B
Assignment B

Topics:

Introduction to structures
Structures to classes
Introduction to classes
Object oriented design

Use the style guide.

Problem B1

The volume of a cone is given by the formula:
V = Π r2 h / 3

For the value of Π use:
const double PI = 3.14159265358979323846;

Declare a structure named: Cone
containing:

height   a double, the height of the cone
radius   a double, the radius of the base of the cone

Create the following functions:

main

input:

setUp:

getVolume:

output:

Put the main function first.
Use the function and variable names specified above.
Arrange the functions in the order listed above.

Test your program with the following data:

height   6
radius   2

Problem B2

Repeat problem B1 with the following changes:

Make Cone a class rather than a struct.
Make the height and radius in the class Cone private.
Make setUp a public member function in the class Cone.
Make getVolume a pubic member function in the class Cone.
Make output a public member function in the class Cone.
The main and input functions will remain global functions, not part of the Cone class.
The main function will call the input, setUp, and output functions.
The return types will all be unchanged.

The parameter lists will change for some of the functions:

Test with the same data.