Question: Program the question in C Create a program that presents the user with a menu that has options to: 1. Compute the area of a
Program the question in C


Create a program that presents the user with a menu that has options to: 1. Compute the area of a square 2. Compute the volume of a sphere 3. Compute the surface area of a cube 4. Quit If the users selects option 4, the program should terminate. If they select options 1, 2, or 3, the program should ask the user to input the appropriate values needed to perform the computation (e.g. side length for a square, radius in the case of a sphere, etc.). The calculation should be carried out and the result should be presented to the user. Assume cm for all lengths. Do not worry about input validation, you can assume the user inputs a number in each case, and you should input and treat the numbers as doubles. Be sure to research how to use scanf to read a double value. Be careful when performing your calculations, make sure that what is output from your program is correct. Use a do-while to present the menu to the user, and a switch statement to handle the menu choice selection and to carry out the desired computation by calling the appropriate function. Create C functions to handle each computation... each function should take in any necessary measurement as an argument/parameter and return the correct computation. The function should not be responsible for asking for the necessary lengths, do this in your main function. All of these functions can be written in one line, they should not be very long at all. For example, a triangle area function would look like: double triangle_area(double base, double height) { return 0.5 * base * height; } Your program should run identically or near identically to this example: 1) Compute the area of a square 2) Compute the volume of a sphere 3) Compute the surface area of a cube 4) Quit Enter an option: 1 Enter the side length (cm): 10 Area of the square: 100.00 (cm) 1) Compute the area of a square 2) Compute the volume of a sphere 3) Compute the surface area of a cube 4) Quit Enter an option: 2 Enter the radius (cm): 10 Volume of the sphere: 4188.79 (cm) 1) Compute the area of a square 2) Compute the volume of a sphere 3) Compute the surface area of a cube 4) Quit Enter an option: 3 Enter the edge of the cube: 10 Surface area of the cube: 600.00 (cm) 1) Compute the area of a square 2) Compute the volume of a sphere 3) Compute the surface area of a cube 4) Quit Enter an option: 4 Goodbye
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
