Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview in C++ For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to

Overview in C++

For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue.

Basic Program Logic

The program should start by displaying a menu similar to the following:

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 the user's choice as an integer.

After the choice has been made, if the user did not choose the quit option, the program should enter a loop that will continue until the user wants to quit.

If the user chose the circle option (1), the program should 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 chose the triangle option (2), the program should prompt them to enter 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 an invalid option (something other than 1, 2, or 3), the program should display an error message about an invalid choice being made.

At the end of the loop, the menu should be displayed to the user again and their new choice should be read.

Program Requirements

  1. All of the calculated areas should be displayed with exactly 3 digits after the decimal point.

image text in transcribed

Sample Output Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice (1-3): 7 **ERROR: 7 is an invalid selection Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice (1-3): 1 What is the radius of the circle? 8 The area of the circle is 201.062 Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice (1-3): 2 What is the length of the base of the triangle? 4 What is the height/altitude of the triangle? 3 The area of the triangle is 6.000 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! Sample Output Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice (1-3): 7 **ERROR: 7 is an invalid selection Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice (1-3): 1 What is the radius of the circle? 8 The area of the circle is 201.062 Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice (1-3): 2 What is the length of the base of the triangle? 4 What is the height/altitude of the triangle? 3 The area of the triangle is 6.000 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Power Bi And Azure Integrating Cloud Analytics For Scalable Solutions

Authors: Kiet Huynh

1st Edition

B0CMHKB85L, 979-8868959943

More Books

Students also viewed these Databases questions