int main()
{
//Local variables
int radious;
double pi = 3.14159;
char choice;
do
{
//Function call
DisplayMenu();
GetChoice(choice);
{
switch (choice)
{
case 1:
cout << "The radious is: " << getRadious() << endl;
break;
case 2:
cout << "The Area is: " << CalcArea(radious, pi) << endl;
break;
case 3:
cout << "The Circumference is: " << CalcCircumference(radious, pi) << endl;
break;
case 4:
cout << "The Diameter is: " << CalcDiameter(radious) << endl;
break;
case 5:
DisplayTable();
break;
system("pause");
//Clear the screen
system("cls");
}
} while (choice != 4);
return 0;
}
void DisplayMenu()
{
//Display the options of the program and ask the user to choose 1 of the 6 options
cout << " CIRCLE APPLICATION " << endl;
cout << "---------------------------------" << endl;
cout << " 1) Get radious " << endl;
cout << " 2) Calculate Area " << endl;
cout << " 3) Calculate circumference " << endl;
cout << " 4) Calculate diameter " << endl;
cout << " 5) Display Table " << endl;
cout << " 6) Exit " << endl;
cout << "---------------------------------" << endl;
}
void GetChoice(char&choice)
{
//Ask the user to enter a option (1-6)
cout << "Enter a choice[1-6]: ";
//input the option
cin >> choice;
while (choice < 1 || choice>6)
{
cout << "Please re-enter a choice [1-6]: ";
cin >> choice;
}
}
void getRadious()
{
int radious;
//Ask the user to enter the radious of the circle
cout << "Enter the radious of the circle: ";
//Input the radious
cin >> radious;
}
//Calculate the area square using the width and length entered by the user
double CalcArea(int radious, double pi = 3.14159)
{
return (pow(radious, 2)*pi);
}
//Calculate the perimeter of the square using the width and length entered by the user
double CalcCircumference(int radious, double pi=3.14159)
{
return (2*radious*pi);
}
int CalcDiameter(int radious)
{
return (2 * radious);
}