Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. Specifications: Create a menu-driven program that finds and displays areas of

ID: 3846914 • Letter: #

Question

.

Specifications:

Create a menu-driven program that finds and displays areas of 3 different objects.

The menu should have the following 4 choices:

1 -- square

2 -- circle

3 -- right triangle

4 -- quit

If the user selects choice 1, the program should find the area of a square.

If the user selects choice 2, the program should find the area of a circle.

If the user selects choice 3, the program should find the area of a right triangle.

If the user selects choice 4, the program should quit without doing anything.

If the user selects anything else (i.e., an invalid choice) an appropriate error message should be printed.

Sample Run

Program to calculate areas of objects

        1 -- square

        2 -- circle

        3 -- right triangle

        4 -- quit

2

Radius of the circle: 3.0

Area = 28.2743

Step 1: Once you have your program working, run it 4 times, each time testing a different valid menu choice. Then run it a fifth time using an invalid menu choice (such as 0 or 5). Make sure your program works correctly for all cases.

Specifications:

Create a menu-driven program that finds and displays areas of 3 different objects.

The menu should have the following 4 choices:

1 -- square

2 -- circle

3 -- right triangle

4 -- quit

If the user selects choice 1, the program should find the area of a square.

If the user selects choice 2, the program should find the area of a circle.

If the user selects choice 3, the program should find the area of a right triangle.

If the user selects choice 4, the program should quit without doing anything.

If the user selects anything else (i.e., an invalid choice) an appropriate error message should be printed.

Sample Run

Program to calculate areas of objects

        1 -- square

        2 -- circle

        3 -- right triangle

        4 -- quit

2

Radius of the circle: 3.0

Area = 28.2743

Explanation / Answer

#nclude<iostream>

#include<cmath>

using namespace std;

int main()

{

char choice;

float radius,area,length,breadth;

do

{

cout<<"select from choices indexed .";

cout<<" 1 - Area of square ";

cout<<" 2 - Area of circle ";

cout<<"3 -Area of right triangle ";

cout<<"4 -Quit ";

cin>>choice;

if(choice=='1')

{

cout<<"enter the square length.";

cin>>length;

cout<<"square area="<<length*length<<" ";

else if(choice=='2')

{

cout<<"Enter circle radius:";

cin>>radius;

area=3.14*radius*radius;

cout<<circle area=";

}

else if(choice='3')

{

cout<<"enter right triangle:";

cin>>length;

cout<<"enter right riangle:";

cin>>breadth;

cout"right triangle area="<<length*breadth/2<<" ";

}

} while(choice != '4' )

  

return 0;

}