Program To Calculate Area Of Shapes in C++

Write a program that displays the following menu: 

Geometry Calculator

1. Calculate the Area of a Circle

2. Calculate the Area of a Rectangle

3. Calculate the Area of a Triangle

4. Quit


**********************************************************************************************************************************************************************************************


 #include<iostream>

#include<iomanip>

using namespace std;

int main()

{

int a;

float R,w,l,h,z,area;

cout <<"1. Calculate The Area of the Circle\n"<<endl;

cout <<"2. Calculate The Area of the Rectangle\n"<<endl;

cout <<"3. Calculate The Area of the Traingle\n"<<endl;

cout <<"4. Quit\n" <<endl;

cout<<"Enter your choice (1-4)\n"<<endl;

cin >>a;

if (a==1)

{ cout<<"Enter a radius"<<endl;

cin>>R;

area =R*R*3.14;

cout<< "The Area of circle is "<<area;

}

else if (a==2)

{cout<<"Enter a length"<<endl;

cin>>l;

cout<<"Enter a width"<<endl;

cin>>w;


area=l*w;

cout <<"The Area of rectangle is "<<area;

}

else if (a==3)

{ cout<<"enter a base "<<endl;

cin>>z;

cout<<"Enter a height"<<endl;

cin>>h;

area=z*h*(1/2);

cout<<"The Area of traingle is "<<area;

}

else { cout<<"The Programe is Quit"<<endl;

}

return 0 ;

}


**********************************************************************************************************************************************************************************************

OUTPUT:






NOTE:   PF LAB #3 Task In BScs

Comments