// Maths Helper
#include <iostream>
// define identifier PI with a constant
#define PI 3.14159
// define identifier TWO with a constant
#define TWO 2.0
usingnamespace std;
char menu()
{
char choice;
cout<< "\nMaths Helper";
cout<< "\n\n**************************************\n";
cout<< "\n\n Please choose one of the following:\n";
cout<< "\n\n 1 - Area of a circle ";
cout<< "\n 2 - Circumference of a circle ";
cout<< "\n 3 - Factorial of a number ";
cout<< "\n 4 - Hypotenuse of a triangle ";
cout<< "\n 5 - Exit";
cout<< "\n\n\n**************************************\n";
cout<< "\n\n Enter you choice and press return: ";
cin >> choice;
return choice;
}
int main()
{
int num,factorial=1,Angle, Opposite;
float area, radius, circumference;
char choice;
do
{
choice = menu();
switch (choice)
{
case'1':
cout << "\n\nArea of a circle"
<< "\n\nEnter the radius:";
cin >> radius;
// area = PI*radius*radius
area = PI * radius * radius;
// circle area
cout << "\nCircle area = " << area << endl;
// Pause for user
system("pause");
break;
case'2':
cout<< "\n\nCircumference of a circle"
<<"\n\nEnter a circumference of a circle:";
cin>>radius;
// circumference = 2*PI*radius
circumference = TWO * PI * radius;
// circle Circumference
cout<<"\nCircumference = "<<circumference<<endl;
// Pause for user
system("pause");
break;
case'3':
cout<< "\n\nFactorial of a number "
<<"\n\nEnter a number to find its factorial:";
cin>>num;
// a = 1, number less then 1 equals number, increase the number by 1
for(int a=1;a<=num;a++)
{
// factorial = 1 *
factorial=factorial*a;
}
//Factorial number
cout<<"\n\nFactorial number is ="<<factorial<<endl;
// Pause for user
system("pause");
break;
case'4':
cout<< "\n\nHypotenuse of a triangle "
<< "\n\n Enter a Angle:";
cin>>Angle;
cout<< "\n\n Enter the Opposite:";
cin>>Opposite;
system("pause");
break;
case'5':
cout<< "Exit";
break;
default:
cout<< "\nNot a valid choice.";
}
} while (choice != '5');
return 0;
}