IUP Computer Science
COSC 110      Spring 2005

Project #2
(Due 9 February 2005)

Ajax Sporting Goods wants to sell a line of awards that are tailored for customers and their sports' interests.  These awards will be in the form of a basketball, softball, baseball, or golf ball, but will be made of metal and will be hollow.  The General Manager has decided to make each award so that it has the same dimensions as the associated ball and its weight exactly matches the weight of an equal volume of water.  By doing this, the awards would just barely float if placed in water - the General Manager has a phobia about losing things in bodies of water.

For purposes of this project, we will regard each ball as a perfect sphere.  The sizes of the balls are known based on their circumferences.  The following small table shows dimensions:
 

Basketball 30 inches
Softball 12 inches
Baseball 9 inches
Golf ball 5.375 inches

In order to construct these awards, Ajax must tell the foundry how thick to make the skin of the spheres so that the awards just barely float on water.  Of course, this thickness depends on the material being used to make the award.  Fortunately, the company's mathematicians have provided a simple formula to help.  If R is the outside radius of the sphere and S is the specific gravity of the material, the thickness, T,  can be calculated as follows:

T = R - cube root of  [ ( (S - 1) * R3 ) / S ]

Since the formula is in terms of the radius and the balls are referred to by their circumference, you need to make a conversion.  Use the conversion:     Circumference =  2  *  pi  *  Radius      There are a number of materials that Ajax is considering using in making the awards.  The following table lists the possible materials and their specific gravities.
 

Magnesium 1.738
Aluminum 2.7
Titanium 4.506
Iron 7.65
Copper 8.85
Silver 10.5
Lead 11.34
Uranium 18.7
Gold 19.32

Calculating the weight of the award is necessary to know how much to charge for it.  The weights of all awards of the same size will be the same because they will all exactly float on water.  So, all that is necessary to get the weight is to find the weight of a volume of water equal to the radius of the sphere.  The mathematicians provide this formula for the weight, W.

W = 4/3 * pi * R3 * 0.03612718

This last number is the weight in pounds of one cubic inch of water.

The final requirement from the foundry is that it needs to know the total volume of the shell.  Again, the mathematicians have come through by telling us that all we need to do to get this information is subtract the volume of the hollow inside  from the outside volume of the sphere.  They say we should use the following formula in which H is the radius of the hollow in the center, R is the outside radius of the sphere and V is the volume:

V = ( 4/3 * pi * R3 ) - ( 4/3 * pi * H3 )

Your job is to write a program that prompts for the circumference of the ball and the specific gravity of the material to be used.  Your program should then display the thickness of the shell, the weight of the material, and the volume of the material to be used in making the award.  The output of your program should look something like this (not including the prompting portions) for a softball award made of titanium.

Sphere of radius 1.90986 inches with specific gravity of 4.506
Sphere thickness is 0.153251 inches
Sphere weight is 1.05421 pounds
Shell volume is 6.47592 cubic inches

Hand in a printout of your program and three sets of execution output.  I will specify two days before the project is due which three combinations of ball and material to use in the execution output.  To get the execution output, I recommend running the program and copy-and-paste the output to a .txt file which you can then print with NotePad.  The printout of your program should be made with Visual Studio, not with a word processor; the printout of the output should not be with a word processor either.  Also, copy your source program (.cpp file) to the P: drive (handin folder).  Be sure to name the file containing the source program after yourself.  For instance, I might name my file   wolfe-p2.cpp