Erwin
Erwin
#include <cmath>
using namespace std;
void mainmenu();
void addition(){
system("cls");
float num1,num2,add;
char prompt, choice;
retry:
system("cls");
cout << "ADDITION:\n";
cout << "What is the 1st Value?: ";
cin >> num1;
cout << "What is the 2nd Value?: ";
cin >> num2;
add=num1+num2;
cout << "The sum of the two Values is: " << add << "\n\n";
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void subtraction(){
system("cls");
float num1,num2,minus;
char prompt, choice;
retry:
system("cls");
cout << "SUBTRACTION:\n";
cout << "What is the 1st Value?: ";
cin >> num1;
cout << "What is the 2nd Value?: ";
cin >> num2;
minus=num1-num2;
cout << "The difference of the two Values is: " << minus << "\n\n";
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void multiplication(){
system("cls");
float num1,num2,times;
char prompt, choice;
retry:
system("cls");
cout << "MULTIPLICATION:\n";
cout << "What is the 1st Value?: ";
cin >> num1;
cout << "What is the 2nd Value?: ";
cin >> num2;
times=num1*num2;
cout << "The product of the two Values is: " << times << "\n\n";
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void division(){
system("cls");
float num1,num2,divide;
char prompt, choice;
retry:
system("cls");
cout << "DIVISION:\n";
cout << "What is the 1st Value?: ";
cin >> num1;
cout << "What is the 2nd Value?: ";
cin >> num2;
divide=num1/num2;
cout << "The sum of the two Values is: " << divide << "\n\n";
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void squareroot(){
float a;
char prompt;
retry:
system("cls");
cout << "SQUARE ROOT:" << "\nEnter a Value: ";
cin >> a;
cout << "\nThe Square Root of " << a << " is: " << sqrt(a) << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void exponent(){
retry:
system("cls");
float a,b;
char prompt, prompt1;
cout << "EXPONENT: \n";
cout << "[a]Squared(^2)";
cout << "\n[b]Cube(^3)\n";
cout << "[c]Nth(^n)\nAnswer: ";
cin >> prompt1;
if(prompt1=='A'||prompt1=='a'){
system("cls");
cout << "SQUARED(^2):\n";
cout << "Enter the Base Number : ";
cin >> a;
cout << "\nThe Squared of \"" << a << "\" is: " << pow(a,2) << endl;
}
else if(prompt1=='B'||prompt1=='b'){
system("cls");
cout << "CUBE(^3):\n";
cout << "Enter the Base Number : ";
cin >> a;
cout << "\nThe Cube of \"" << a << "\" is: " << pow(a,3) << endl;
}
else if(prompt1=='C'||prompt1=='c'){
system("cls");
cout << "Nth(^n):\n";
cout << "Enter the Base Number: ";
cin >> a;
cout << "Enter the Exponent Number : ";
cin >> b;
cout << "\nThe Answer to \"" << a << "^" << b << "\" is: " << pow(a,b) << endl;
}
else{
cout << "Wrong Input. Please try again. ";
system("pause");
goto retry;
}
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void factorial(){
retry:
system("cls");
float num, factorial=1;
char prompt;
cout << "FACTORIAL: \n";
cout << "Enter a Value: ";
cin >> num;
for(int a=1; a <= num; a++){
factorial=factorial*a;
}
cout << "\nThe Answer to \"" << num << "!\" is: " << factorial << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void sine(){
float a, prompt1;
float PI = 3.14159265;
char prompt;
retry:
system("cls");
cout << "SINE:";
cout << "\nCalculate Sine values in:\n[1]Degree\n[2]Radian\nAnswer: ";
cin >> prompt1;
if(prompt1==2){
cout << "SOLVE FOR SIN VALUE IN RADIAN FORM:\n";
cout << "\nEnter a Value: ";
cin >> a;
cout << "\nThe Sin of " << a << " in Radian is: " << sin(a) << endl;
}
else if(prompt1==1){
cout << "SOLVE FOR SIN VALUE IN DEGREE FORM:\n";
cout << "\nEnter a Value: ";
cin >> a;
cout << "\nThe Sin of " << a << " in Degree is: " << sin(a*PI/180.0) << endl;
}
else{
cout << "Wrong Input. Try again. ";
system("pause");
goto retry;
}
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void cosine(){
float a, prompt1;
float PI = 3.14159265;
char prompt;
retry:
system("cls");
cout << "CINE:";
cout << "\nCalculate Cosine values in:\n[1]Degree\n[2]Radian\nAnswer: ";
cin >> prompt1;
if(prompt1==2){
cout << "SOLVE FOR COS VALUE IN RADIAN FORM:\n";
cout << "\nEnter a Value: ";
cin >> a;
cout << "\nThe Cos of " << a << " in Radian is: " << cos(a) << endl;
}
else if(prompt1==1){
cout << "SOLVE FOR COS VALUE IN DEGREE FORM:\n";
cout << "\nEnter a Value: ";
cin >> a;
cout << "\nThe Cos of " << a << " in Degree is: " << cos(a*PI/180.0) << endl;
}
else{
cout << "Wrong Input. Try again. ";
system("pause");
goto retry;
}
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void tangent(){
float a, prompt1;
float PI = 3.14159265;
char prompt;
retry:
system("cls");
cout << "TANGENT: ";
cout << "\nCalculate Tangent values in:\n[1]Degree\n[2]Radian\nAnswer: ";
cin >> prompt1;
if(prompt1==2){
cout << "SOLVE FOR TAN VALUE IN RADIAN FORM:\n";
cout << "\nEnter a Value: ";
cin >> a;
cout << "\nThe Tan of " << a << " in Radian is: " << tan(a) << endl;
}
else if(prompt1==1){
cout << "SOLVE FOR TAN VALUE IN DEGREE FORM:\n";
cout << "\nEnter a Value: ";
cin >> a;
cout << "\nThe Tan of " << a << " in Degree is: " << tan(a*PI/180.0) << endl;
}
else{
cout << "Wrong Input. Try again. ";
system("pause");
goto retry;
}
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
void pi(){
float result, a, prompt1;
float PI = 3.14159265;
char prompt;
retry:
system("cls");
cout << "Solve for PI:\n";
cout << "Enter a value: ";
cin >> a;
result=a*PI;
cout << "\nThe answer to \"" << a << " times PI\" is: " << result << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void euler(){
float a, prompt1;
char prompt;
retry:
system("cls");
cout << "EULER'S NUMBER:\n";
cout << "Enter a Value: ";
cin >> a;
cout << "\nThe answer to \"e^" << a << "\" is: " << exp(a) << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void triangle(){
float h,b, prompt1;
char prompt;
retry:
system("cls");
cout << "AREA OF A TRIANGLE:\n";
cout << "Enter its height: ";
cin >> h;
cout << "Enter its base: ";
cin >> b;
cout << "\nThe Area of the triangle is: " << (0.5)*h*b << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void square(){
float a, prompt1;
char prompt;
retry:
system("cls");
cout << "AREA OF A SQUARE:\n";
cout << "Enter its Base/Height: ";
cin >> a;
cout << "\nThe Area of the SQUARE is: " << a*a << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void circle(){
float r, prompt1;
float PI = 3.14159265;
char prompt;
retry:
system("cls");
cout << "AREA OF A CIRCLE: \n";
cout << "Enter its radius: ";
cin >> r;
cout << "\nThe area of the circle is: " << (r*r)*PI << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void rectangle(){
float l,w, prompt1;
char prompt;
retry:
system("cls");
cout << "AREA OF A RECTANGLE:\n";
cout << "Enter its length: ";
cin >> l;
cout << "Enter its width: ";
cin >> w;
cout << "\nThe Area of the rectangle is: " << w*l << endl;
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void prism(){
float h,b,l,w;
char prompt, prompt1;
retry:
system("cls");
cout << "VOLUME OF PRISM:\n";
cout << "[a]Triangular Prism\n";
cout << "[b]Square Prism\n";
cout << "[c]Rectangular Prism\nAnswer: ";
cin >> prompt1;
if(prompt1=='A'||prompt1=='a'){
system("cls");
cout << "TRIANGULAR PRISM:\n";
cout << "Enter its Base: ";
cin >> b;
cout << "Enter its Height: ";
cin >> h;
cout << "Enter its Length: ";
cin >> l;
cout << "The Volume of the Triangular Prism is: " << (b*h*l)/2 << endl;
}
else if(prompt1=='B'||prompt1=='b'){
system("cls");
cout << "SQUARE PRISM:\n";
cout << "Enter its Height: ";
cin >> h;
cout << "Enter its Length: ";
cin >> l;
cout << "The Volume of the Triangular Prism is: " << (l*l)*h << endl;
}
else if(prompt1=='C'||prompt1=='c'){
system("cls");
cout << "RECTANGULAR PRISM:\n";
cout << "Enter its Width: ";
cin >> w;
cout << "Enter its Height: ";
cin >> h;
cout << "Enter its Length: ";
cin >> l;
cout << "The Volume of the Triangular Prism is: " << w*h*l << endl;
}
else{
cout << "Wrong Input. Please try again. ";
system("pause");
goto retry;
}
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void cylinder(){
float h,r;
float PI = 3.14159265;
char prompt;
retry:
system("cls");
cout << "VOLUME OF A RIGHT CYLINDER:\n";
void pyramid(){
float b,h,h1,l,w,a;
char prompt, prompt1;
retry:
system("cls");
cout << "VOLUME OF A PYRAMID:\n";
cout << "[a]Triangular Pyramid\n";
cout << "[b]Square Pyramid\n";
cout << "[c]Rectangular Pyramid\nAnswer: ";
cin >> prompt1;
if(prompt1=='A'||prompt1=='a'){
system("cls");
cout << "TRIANGULAR PYRAMID:\n";
cout << "Enter the Base of the pyramid: ";
cin >> b;
cout << "Enter the Height of the base of the triangle: ";
cin >> h1;
cout << "Enter the Height of the pyramid: ";
cin >> h;
a=(b*h1)/2;
cout << "\nThe Volume of the Triangular Pyramid is: " << (a*h)/3 <<
endl;
}
else if(prompt1=='B'||prompt1=='b'){
system("cls");
cout << "SQUARE PYRAMID:\n";
cout << "Enter its Length: ";
cin >> l;
cout << "Enter its Height: ";
cin >> h;
cout << "\nThe Volume of the Square Pyramid is: " << ((l*l)*h)/3 <<
endl;
}
else if(prompt1=='C'||prompt1=='c'){
system("cls");
cout << "RECTANGULAR PYRAMID\n";
cout << "Enter its Height: ";
cin >> h;
cout << "Enter its Length: ";
cin >> l;
cout << "Enter its Width: ";
cin >> w;
cout << "\nThe Volume of the Rectangular Pyramid is: " << (w*h*l)/3 <<
endl;
}
else{
cout << "Wrong Input. Please try again. ";
system("pause");
goto retry;
}
cout << "Do you want to try again?(Y/N): ";
cin >> prompt;
if(prompt=='Y'||prompt=='y'){
cout << "Resetting. ";
system("pause");
goto retry;
}
else if(prompt=='N'||prompt=='n'){
cout << "Returning back to Main Menu. ";
system("pause");
mainmenu();
}
else{
cout << "Invalid Input, Returning to Main Menu. ";
system("pause");
mainmenu();
}
}
void mainmenu(){
system("cls");
int prompt, prompt1;
if(prompt1==1){
addition();
}
else if(prompt1==2){
subtraction();
}
else if(prompt1==3){
multiplication();
}
else if(prompt1==4){
division();
}
else if(prompt1==5){
squareroot();
}
else if(prompt1==6){
factorial();
}
else if(prompt1==7){
pi();
}
else if(prompt1==8){
sine();
}
else if(prompt1==9){
cosine();
}
else if(prompt1==10){
tangent();
}
else if(prompt1==11){
prism();
}
else if(prompt1==12){
cylinder();
}
else if(prompt1==13){
pyramid();
}
else if(prompt1==14){
euler();
}
else if(prompt1==15){
exponent();
}
else if(prompt1==16){
triangle();
}
else if(prompt1==17){
circle();
}
else if(prompt1==18){
rectangle();
}
else if(prompt1==19){
square();
}
else if(prompt1==0||prompt1==0){
cout << "Exitting Program.";
}
else{
int main(){
mainmenu();
return 0;
}