why no switch structure ?
switch is the best thing you can use for a console menu
here is my solution with switch:
#include <iostream>
using namespace std;
int main()
{
int Menu;
double pi = 3.14159265;
double A, r, h, g, a, b;
do{
cout << "\nChoose an option: ";
cin >> Menu;
switch(Menu){
case 1:
cout << "\nCalculate the Area of a circle";
cout << "\nType in the value for r: ";
cin >> r;
A = r * r * pi;
cout << "The Area of the circle is: " << A;
break;
case 2:
cout << "\nCalculate the Area of a rectangle: ";
cout << "\nType in the value of a: ";
cin >> a;
cout << "Type in the value of b: ";
cin >> b;
A = a * b;
cout << "The Area of the rectangle is: " << A;
break;
case 3:
cout << "\nCalculate the Area of a Triangle: ";
cout << "\nType in the value for the height h: ";
cin >> h;
cout << "Type in the value for g: ";
cin >> g;
A = 0.5 * g * h;
cout << "The Area of the triangle is: " << A;
break;
case 4:
cout << "\nThe End!";
break;
default:
cout << "Error! Not a valid option!";
break;
}
}while(Menu != 4);
return 0;
}
if you dont want to use switch just do it with if statements for example:
if(Menu == 1){
cout << "Area of a circle";
}