#include <iostream>
#include <string>
usingnamespace std;
void Add(int a,int b)
{
cout<<"The Add result is: "<<a+b<<endl;
}
void Mult(int a,int b)
{
cout<<"The Mult result is: "<<a*b<<endl;
}
void Sub(int a,int b)
{
int d = a-b;
if(d<0)
{
char choice;
cout<<"the answer is samller than 0 which mean it's in the negative numbers"<<endl<<"Do you want to renter the two number (answer with y for yes and n for no)"<<endl;
cin>>choice;
if(choice == 'y'|| choice == 'Y')
{
cout<<"please enter the first number"<<endl;
cin>>a;
cout<<"please enter the second number"<<endl;
cin>>b;
}
}
cout<<"The sub result is: "<<a-b<<endl;
}
void Divide(int a,int b)
{
while(b == 0)
{
cout<<"there is no operation over zero"<<endl<<"please renter the over number"<<endl;
cin>>b;
}
cout<<"The Divide result is: "<<a/b<<endl;
}
int Main()
{
int x,z;
char m = 'y';
char operationchoice;
cout<<"Wlcome to Ahmed Sayed Moussa Calcalter using C++ code ^_^ "<<endl;
while(m == 'y' || m == 'Y')
{
cout<<"Enter the first number , the operation sign then the second number"<<endl;
cin>>x>>operationchoice>>z;
switch(operationchoice)
{
case'/':
Divide(x,z);
break;
case'+':
Add(x,z);
break;
case'-':
Sub(x,z);
break;
case'*':
Mult(x,z);
break;
}
cout<<"Do You Want To Make any more operations (asnwer with y for yes and no for no)"<<endl;
cin>>m;
}
return 0;
}
void HelpMenu()
{
cout<<"Help Menu"<<endl;
cout<<"Enter the first number , the operation sign then the second number"<<endl;
cout<<"-----------------------------"<<endl;
}
void Sign()
{
cout<<"Enter + for Add"<<endl;
cout<<"Enter - for Sub"<<endl;
cout<<"Enter * for Mult"<<endl;
cout<<"Enter / for Divide"<<endl;
cout<<"-----------------------------"<<endl;
}
void SubMenu()
{
int r;
cout<<"Enter 1 for Help Menu"<<endl<<"Enter 2 for the Sign Menu"<<endl;
cin>>r;
if(r == 1)
{
HelpMenu();
}
if(r == 2)
{
Sign();
}
else
{
cout<<"Please enter number 1 or 2 and not a thired number"<<endl;
SubMenu();
}
}