Just when you thought it was safe to forget geometry, your boss asks you to write a program that will compute various information regarding triangles, squares, rectangle, circles, and cubes.
Your program should first display instructions and the following menu (color is just for highlighting):
Welcome to the Shape Information Program!
Press the number in parentheses to calculate
information regarding one of the following shapes:
(1) Triangles (2) Squares (3) Rectangles (4) Circles (5) Cubes
For example, a 1 is acceptable input to start the calculation for a triangle.
Assuming the user types in the correct number for a triangle, square, rectangle or circle, the user should then be given the option of calculating the area or the perimeter (known as circumference for a circle) of the shape. The user is to be asked to type 1 for the area, 2 for the perimeter or circumference).
If the user types the correct number for a cube, (s)he should be prompted to choose between the volume and the surface area. The user is to be asked to type 1 for volume and 2 for surface area.
Have the program error handle all invalid numbers by displaying the message, "The number [<the specific number entered>] is an invalid choice: program will terminate, " and then end the program. Be sure to have the computer display the bad number within the error message.
See "Notes and Hints" below for additional requirements.
The formulae are as follows:
Triangle:
Area= .5 * base * height
Perimeter = 3 * Side (assume an equilateral triangle).
Square:
Area = side^{2}
Perimeter = 4 * side
Rectangle:
Area = base * height
Perimeter = 2 * base + 2 * height
Circle:
Area = PI * radius^{2}
Circumference = 2 * PI * radius
Cube:
Volume = side^{3}
Surface Area = 6 * side^{2}
Notes & Hints:
SAMPLE RUN # 1
Welcome to the Shape Information Program!
Press the number in parentheses to calculate
information regarding one of the following shapes:
(1) Triangles (2) Squares (3) Rectangles (4) Circles (5) Cubes
3
Would you like to find the (1) Area or (2) Perimeter?
1
Please type in the length of the base and height:
2.5 1.3
The area is 3.25
SAMPLE RUN # 2
Welcome to the Shape Information Program!
Press the number in parentheses to calculate
information regarding one of the following shapes:
(1) Triangles (2) Squares (3) Rectangles (4) Circles (5) Cubes
5
Would you like to find the (1) Volume or (2) Surface Area?
1
Please type in the length of the side:
3
The volume is
27.00
SAMPLE RUN # 3
Welcome to the Shape Information Program!
Press the number in parentheses to calculate
information regarding one of the following shapes:
(1) Triangles (2) Squares (3) Rectangles (4) Circles (5) Cubes
4
Would you like to find the (1) Area or (2) Circumference?
2
Please type in the length of the radius:
5
The circumference
is 31.40
SUBMISSION INSTRUCTIONS
You must submit BOTH
an email copy of your .c file only to the grader
AND
a printout of .c file and output (sample runs) to
me in class (make
sure you have your name on both)
Your email MUST have the following in the Subject line to ensure you are not penalized for non or late submission!
INTROC:YOUR LAST NAME:YOUR FIRST NAME:HW#2
If it's late or you are allowed to resubmit, then follow the above with :LATE or :RESUBMIT as is applicable.
The grader's email is: aev208@nyu.edu. Please do NOT ask the grader questions. Questions should be directed to the list if general, or to me if more specific.
Good luck!