For this assignment, write a program that will act as a geometry calculator. Sou
ID: 441151 • Letter: F
Question
For this assignment, write a program that will act as a geometry calculator. Sound familiar? Modify program 2 so that it can handle more than one shape when it is run (this will be accomplished by adding a loop) and use a cascading decision statement to handle the various shapes and error checking. As with program 2, display a menu to the user: Geometry Calculator. 1. Calculate the area of a circle. 2. Calculate the area of a triangle. 3. Calculate the area of a parallelogram. 4. Calculate the area of a trapezoid. 5. Calculate the area of an ellipse. 6. Quit Enter your choice (1-6): and get their choice. Cascading Decision Statement The cascading decision statement should be used to handle the various shapes and do the error checking. The handling of options 1 and 2 (the circle and triangle) is the same as in program 3. For option 3, the program should prompt the user to enter the length of the base of a parallelogram and its height. Those values should then be used to calculate the area of a parallelogram using the formula: Area of a Parallelogram = base * height. For option 4, the program should prompt the user for the length of the two bases (the two parallel sides) of the trapezoid (NOTE: 2 separate values) and its height. Those values should then be used to calculate the area of a trapezoid using the formula: Area of a Trapezoid = 1/2 * (length of base 1 + length of base 2) * height. For option 5, the program should prompt the user for the length of the semi-major axis (this is half the length of the widest diameter of the ellipse) and the length of the semi-minor axis (this is half the length of the narrowest diameter of the ellipse) of the ellipse. Those values should then be used to calculate the area of an ellipse using the formula: Area of an Ellipse = ? * length of Semi-Major Axis * length of Semi-Minor Axis. For anything other than 1 through 6, the program should display an error message. Loop The cascading decision statement should be placed inside of a loop so that more that the area of more than one shape can be calculated and displayed when the program is run. This loop should continue to execute as long as the user has not selected option 6 from the menu. As with program 2, if the user selects the option to quit (option 6 in this program), the program should display "Goodbye!" and then end. This should be placed outside of the loop. Processing Requirements At the top of your C++ source code, include a documentation box that resembles the one from programs 1 and 2. This will be a part of every program that is submitted during the semester and will be the last reminder in the program write-ups. Include line documentation. There is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describes what the "chunk" of code does. This will also be a part of every program that is submitted for the remainder of the semester. All of the calculated areas should be displayed with exactly 2 digits after the decimal point. The numeric values read in from the user should all be integer values. The calculated areas should all be float or double values. Use meaningful variable names. Make sure and test your program with values that you have calculated. Hand in a copy of your source code (the CPP file) using Blackboard. Output A few runs of the program should produce the following results: Run 1 Geometry Calculator. 1. Calculate the area of a circle. 2. Calculate the area of a triangle. 3. Calculate the area of a parallelogram. 4. Calculate the area of a trapezoid. 5. Calculate the area of an ellipse. 6. Quit. Enter your choice (1-6): 5. Enter the length of the Semi-Major Axis: 7. Enter the length of the Semi-Minor Axis: 3. The area of the ellipse is 65.97. Geometry Calculator. 1. Calculate the area of a circle. 2. Calculate the area of a triangle. 3. Calculate the area of a parallelogram. 4. Calculate the area of a trapezoid. 5. Calculate the area of an ellipse. 6. Quit. Enter your choice (1-6): 1. Enter the radius: 15. The area of the circle is 706.86. Geometry Calculator. 1. Calculate the area of a circle. 2. Calculate the area of a triangle. 3. Calculate the area of a parallelogram. 4. Calculate the area of a trapezoid. 5. Calculate the area of an ellipse. 6. Quit. Enter your choice (1-6): 3. Enter the length of the base: 6. Enter the height: 4. The area of the parallelogram is 24.00. Geometry Calculator. 1. Calculate the area of a circle. 2. Calculate the area of a triangle. 3. Calculate the area of a parallelogram. 4. Calculate the area of a trapezoid. 5. Calculate the area of an ellipse. 6. Quit. Enter your choice (1-6): 7. 7 is an invalid option. Geometry Calculator. 1. Calculate the area of a circle. 2. Calculate the area of a triangle. 3. Calculate the area of a parallelogram. 4. Calculate the area of a trapezoid. 5. Calculate the area of an ellipse. 6. Quit/ Enter your choice (1-6): 4. Enter the length of the first base: 10. Enter the length of the other base: 17. Enter the height: 5. The area of the trapezoid is 67.50. Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Calculate the area of a parallelogram 4. Calculate the area of a trapezoid 5. Calculate the area of an ellipse 6. Quit Enter your choice (1-6): 2 Enter the length of the base: 3 Enter the height: 4 The area of the triangle is 6.00 Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Calculate the area of a parallelogram 4. Calculate the area of a trapezoid 5. Calculate the area of an ellipse 6. Quit Enter your choice (1-6): 9 9 is an invalid option Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Calculate the area of a parallelogram 4. Calculate the area of a trapezoid 5. Calculate the area of an ellipse 6. Quit Enter your choice (1-6): 6 Goodbye!Explanation / Answer
There are 2 things you can do. 1. Type the formulas into your calculator. (easy) - Hit PRGM button, hit left arrow, hit enter. Type a name (using ALPHA key), hit enter. Now, type the equations using the ALPHA key. To see this in the future, go to PRGM, right arrow, and hit enter on your program. 2. Make a program that displays it. (hard) - Make a new program the same way as above. This time, instead of just typing the formula, hit PRGM, right arrow, 3. Now type the equation within quotes (ALPHA and "+"). To run this, go to PRGM, and hit enter on your program.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.