## V22.0002 - ASSIGNMENT 2

Revised-- see italics below
(you no longer use character input)

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 = side2

Perimeter = 4 * side

Rectangle:

Area = base * height

Perimeter = 2 * base + 2 * height

Circle:

Circumference = 2 * PI * radius

Cube:

Volume = side3

Surface Area = 6 * side2

Notes & Hints:

• You must create and use a constant for PI (3.14).
• Use cases in the switch to handle each valid number for selecting shapes and if statements for the particular information to calculate.
• Only use the variables relevant for the proper execution.  (Your program shouldn't use a radius variable when computing information regarding triangles, etc.).
• Have the program display all answers to TWO decimal places.
For example, the following would be a valid execution of the program (the blue is displayed by the computer, and the red represents the user's input):

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

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!