Project 5

Due: 26 Nov

Requirements Specification

Write the C code for computing the radius, circumference, surface area and volume of a sphere given the diameter. Use functions to do this project.

Your program must have the following functions:

  1. GetInput :- Get a decimal number greater than or equal to 0.0 from the user. Do error checking and ask again.
  2. GetOption :- Get the option from the user. R for radius, C for circumference, S for surface area , V for volume or Q to quit. Do error checking.
  3. Radius :- Compute the radius of the sphere and display the result.
  4. Circumference:- Compute the circumference of the sphere and display the result.
  5. SurfaceArea :- Compute the surface area of the sphere and display the result.
  6. Volume:- Compute the volume of the sphere and display the result.
The functions should have the names mentioned above. Also the program should keep asking for option unless the user wants to quit.

Name the source code file: proj5.c

Submission

Email the source file (the .c file) as an attachment to the TA at dipesh1@umbc.edu.

The subject of the email should be "CMSC104 Section 0701 Project 5". This must be an exact match for the TA to be able to filter the mail and put your work in the correct folder! Write your name, last four digits of your social security number and your section number in the body of the email. Please follow all this instructions and make sure that you have met them before sending the email. Don't send a copy to me. You will lose points if you don't follow the instructions.

Example Output

In the following example, the program displays what is in Blue and the user types what is in Red.

Enter diameter in meters: -1.11
Must be greater than 0.0. Try again.
Enter diameter in meters: 2.0
Compute what?
R : Radius
C : Circumference
S : Surface Area
V : Volume
Q : Exit
Enter Selection : R

Radius is 1.000 meters

Compute what?
R : Radius
C : Circumference
S : Surface Area
V : Volume
Q : Exit
Enter Selection : A

Surface Area is 12.566 square meters

Compute what?
R : Radius
C : Circumference
S : Surface Area
V : Volume
Q : Exit
Enter Selection : V

Volume is 1.488 cubic meters

Compute what?
R : Radius
C : Circumference
S : Surface Area
V : Volume
Q : Exit
Enter Selection : C

Circumference is 6.283 meters

Compute what?
R : Radius
C : Circumference
S : Surface Area
V : Volume
Q : Exit
Enter Selection : Q

Quitting !!
 

-- Remember the program keeps on asking for options unless the user wants to quit.
-- You will have to use the exit() function to do this project.

Program Header Comment Block

Use the following comment block at the beginning of your source code:
/* 
** Filename:       proj5.c
** Name:           Your name
** SSAN:           Last four digits of your SSN   
** Date:           Date of submission
** Course:         CMSC-104 Section XXX 
** Description:    (Your psuedocode goes here.  Must be detailed)
** Notes:          (As needed, such as how to compile)
*/


You will lose points if you don't follow the instructions for the Header Comment Block.