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

Write a c++ program that displays the following menu:Geometry Calculator1.Calcul

ID: 3891017 • Letter: W

Question

Write a c++ program that displays the following menu:Geometry Calculator1.Calculate the Area of a Circle2.Calculate the Area of a Rectangle3.Calculate the Area of a Triangle4.QuitEnter your choice (1-4):If the user enters 1, the program should ask for the radius of a circle and display its area. Use the following formula:Use 3.14159 for and the radius of the circle for r. If the user enters 2, the program should ask for the length and width of a rectangle and then display the rectangle's area. Use the following formula:area=length*widthIf the user enters 3 the program should ask for the length of a triangle's base and its height, and then display its area. Use the following formula:area=base*height*0.5If the user enters 4, the program should end.Last Modified: 09/14/17area=r2 Input validation: Display an error message if the user enters a number outside the range of 1 through 4when selecting an item for the menu. Do not accept negative values for the circle's radius, the rectangle's length or width, the triangle's base or height

Explanation / Answer

#include <iostream>

using namespace std;

int main() {

// your code goes here

int c;

float rad,h,base,len,wid;

float ar_tri,ar_rec,ar_cir;

cout<<"Enter the choice Between 1-4: 1.1.Calculate the Area of a Circle 2.Calculate the Area of a Rectangle 3.Calculate the Area of a Triangle 4.Quit ";

cin>>c;

switch(c)

{

case 1:

cout<<"Enter the Radius:";

cin>>rad;

ar_cir=3.14159*rad*rad;

cout<<"Area of circle:"<<ar_cir;

break;

case 2:

cout<<"Enter the Length and width:";

cin>>len>>wid;

ar_rec=len*wid;

cout<<"Area of Rectangle:"<<ar_rec;

break;

case 3:

cout<<"Enter the height and base:";

cin>>h>>base;

ar_tri=base*h*0.5;

cout<<"Area of Triangle:"<<ar_tri;

break;

case 4:

exit;

default:

cout<<"Enter the Valid option";

}

return 0;

}

Output:

Enter the choice Between 1-4:
1.1.Calculate the Area of a Circle
2.Calculate the Area of a Rectangle
3.Calculate the Area of a Triangle
4.Quit

1

Enter the Radius:4

Area of circle:50.2654

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote