what is the flowchart and the pseudo-code for this problem ? Using C++ the follo
ID: 673596 • Letter: W
Question
what is the flowchart and the pseudo-code for this problem ?
Using C++ the following program should be modular
My exercise asks me to write a program (geometry.cpp) that displays the following menu:
Geometry Calculator:
1. Calculate the area of a circle
2. calculate the area of a rectangular
3. calculate the area of a triangle
4. quit
Enter your choice (1-4)
-if the user enters 1, then the program should ask for the radius of the circle and then should display the area. use 3.14159 for PI.
- if the user enters 2, then the program should ask for the width and length of the rectangle and then should display the area.
- if the user enter 3, then the program should ask for the length of the triangle base and its height and then should display the area.
- if the user enters 4, then the program should quit.
Explanation / Answer
#include<iostream.h>
#include<conio.h>
class a
{
public:
float area;
void cir()
{
int r;
cout<<"Enter radius";
cin >> r;
area=3.14159*r*r;
cout<<"Area of circle is "<<area;
}
void rect()
{
int w, l;
cout<<"Enter Width and Length";
cin>>w>>l;
area=w*l;
cout<<"Area of Rectangle is"<<area;
}
void tri()
{
int h, b;
cout<<"Enter Base and Height";
cin>>b>>h;
area=0.5*b*h ;
cout<<"Area of Triangle is"<<area;
}
};
void main()
{
a o;
int ans;
cout<<"1. Calculate the area of a circle";
cout<<" 2. calculate the area of a rectangular";
cout<<" 3. calculate the area of a triangle";
cout<<" 4. quit";
cout<<" Enter your choice (1-4)";
cin>>ans;
switch (ans)
{
case 1:
o.cir();
break;
case 2:
o.rect();
break;
case 3:
o.tri();
break;
case 4:
return;
break;
default:
cout<<"Enter number between 1-4 only";
break;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.