Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to choose from the menu to calculate each area for each shape? so far it does not let me choose other thing that 1

How to choose from the menu to calculate each area for each shape? so far it does not let me choose other thing that 1 because all the numbers that I enter give me the option one to calculate area for square. I need to make the program ask what choice leaving the menu there and and then ask what it needs to calculate each. It is c++ programming and I have to use do while loop.

#include #include using namespace std; //Declare your variables// double side, base, height, width, length, radius, Areasq, Arearec, Areatri, Areacir; const double pi = 3.1416;//Use constant for pi so you do not have to keep plugging the number// int main() //Create a menu to be able to choose what you want to calculate// { int choice; do { cout << endl << "1. Area for a square. " << "2. Area for a rectangle. " << "3. Area for a triangle. " << "4. Area for a circle. " << "5. EXIT. " << "Enter your choice and press return:"; cin >> choice; { switch (choice)//It should switch from one option to the other// Case1: cout << " Enter the side value and press ENTER: " << endl; cin >> side; Areasq = side * side; cout << " Area: " << Areasq << "m^2" << endl; break; switch (choice) Case2: cout << " Enter width and length and press ENTER: " << endl; cin >> width, length; Arearec = width * length; cout << " Area = " << Arearec << "m^2" << endl; break; switch (choice) Case3: cout << "Enter the base and height for the triangle and press ENTER:" << endl; cin >> base, height; Areatri = (1/2)*(base * height); cout << " Area = " << Areatri << "m^2" << endl; break; switch (choice) Case4: cout << " Enter the radius for calculating the circle area: " << endl; cin >> radius; Areacir = pi * radius * radius; cout << " Area = " << Areacir << " m^2 " << endl; break; } } while (choice != 5); return (0); }

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

Students also viewed these Databases questions

Question

Describe the estate planning process.

Answered: 1 week ago

Question

Explain what a feasibility analysis is and why its important.

Answered: 1 week ago

Question

1. Television more Over watching faceing of many problems ?

Answered: 1 week ago

Question

Is there a link between chronic stress and memory function?

Answered: 1 week ago