#include<iostream>
#include<cmath>
using namespace std;
int main(){
float a,b,z,m,n,p,r,s;
int x,y,q;
char c;
cout<<"Choose a claculator by typing 1 or 2 or 3 "<<endl;
cout<<"1. Standard"<<endl;
cout<<"2. Scientific"<<endl;
cout<<"3. Trigonometric"<<endl;
cin>>x;
if(x==1){
cout<<"Please enter your calculation in the following format a+b"<<endl;
cin>>a>>c>>b;
switch(c){
case('+'):
cout<<"The results is "<<a+b<<endl;
break;
case ('-'):
cout<<"The result is "<<a-b<<endl;
case('*'):
cout<<"The results is "<<a*b<<endl;
break;
case('/'):
cout<<"The results is "<<a/b<<endl;
break;
}
}
if(x==2){
cout<<"Choose a operation by typing 1 or 2 or 3 "<<endl;
cout<<"1.log"<<endl;
cout<<"2.sqrt"<<endl;
cout<<"3.power"<<endl;
cin>>y;
if(y==1){
cout<<"Please enter any positive number "<<endl;
cin>>z;
cout<<"The results is"<<log(z)<<endl; };
if(y==2){
cout<<"Please enter any positive number "<<endl;
cin>>m;
cout<<"The resuots is "<<sqrt(m)<<endl;};
if(y==3){
cout<<"please 1st enter number and than power "<<endl;
cin>>n>>p;
cout<<"The results is "<<pow(n,p)<<endl;
};
};
if(x==3){
cout<<"choose aoperation by typing 1 or 2 or 3 "<<endl;
cout<<"1) sine"<<endl;
cout<<"2) cosine"<<endl;
cout<<"3) tan"<<endl;
cin>>q;
cout<<"please enter your angle in degree"<<endl;
cin>>r;
s=(r*3.1416)/180 ;
if(q==1)
cout<<"The results is "<<sin(s)<<endl;
else if(q==2)
cout<<"The results is "<<cos(s)<<endl;
else if(q==3)
cout<<cout<<"The results is "<<tan(s)<<endl;
};
system("pause");
return 0;
}
This is what i have so far but i dont know how to Input validation. Each input needs to be validated to check if it was acceptable. if not, you give the user another chance to try again and The program menu should The program should end only when the user chooses the Quit option