For this assignment, write a program that will act as a geometry calculator. The
ID: 3528144 • Letter: F
Question
For this assignment, write a program that will act as a geometry calculator. The program should display the following menu to the user: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get their choice. For this assignment, you may assume that when the user enters their choice, it will be valid (ie. it will either be 1, 2, or 3). After the choice has been made, if the user entered 1, the program should then prompt them to enter the radius of a circle. That value should then be used to calculate the area of a circle using the formula: Area of a Circle = ?r2 where r is the radius of the circle. Use the value 3.14159 as the value for pi. If the user entered 2, the program should then prompt them for the length of the triangles base and and its height. Those values should then be used to calculate the area of a triangle using the formula: Area of a Triangle = 1/2 * base * height If the user entered 3, the program should display "Goodbye!" and then end. Processing Requirements At the top of your C++ source code, include a documentation box that resembles the one from program 1. 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 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. Quit Enter your choice(1-3): 1 Enter the radius: 2 The area of the circle is 12.57 Run 2 Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): 2 Enter the length of the base: 5 Enter the height: 3 The area of the triangle is 7.50 Run 3 Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): 3 Goodbye!Explanation / Answer
# include int main() { int choice, b, h, r; float area; printf( " Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit" ); printf( " Enter your choice(1-3): " ); scanf( "%d", &choice ); switch( choice ) { case 1: printf( " Enter the radius: " ); scanf( "%d", &r ); area = 3.14159 * r * r; printf( " The area of circle is %.2f", area ); break; case 2: printf( " Enter the length of the base: " ); scanf( "%d", &b ); printf( " Enter the height: 3: " ); scanf( "%d", &h ); area = 0.50 * b * h; printf( " The area of the triangle %.2f", area ); break; case 3: printf( " Goodbye!" ); break; } return 0; }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.