#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
void calcTool();
void dispOptions();
int main(){
int ui(1);
while (ui){
dispOptions();
cin>>ui;
cin.ignore();
switch (ui){
case 1:
calcTool();
break;
default:
break;
} //End switch
}
cin.get();
return 0;
}
void dispOptions(){
cout << "-------------MAIN-MENU-------------"<<endl;
cout<<"Enter 1 for Calculator"<<endl;
cout<<"Enter another number to exit"<<endl;
cout << "-----------------------------------"<<endl;
cout <<"Choice: ";
}
void calcTool(){
double left, right; // Operands
char oper; // Operator
double result; // Resulting value
cout << "---------------------------"<<endl;
cout<<"Welcome to Calculator"<<endl;
cout << "---------------------------"<<endl;
cout<<"Only + - * and / are valid operators"<<endl;
cout << "---------------------------"<<endl;
cout << "Please note that if any value is (example) 6.02e23"<<endl;
cout << "It simply means 6.02 x 10^23"<<endl;
cout << "If the value is (example) 1.6e-19"<<endl;
cout << "It simply means 1.6 x 10^-19"<<endl;
cout << "---------------------------"<<endl;
cout<<"Please enter your sum"<<endl;
while (cin >> left >> oper >> right) {
switch (oper) {
case '+': result = left + right;
break;
case '-': result = left - right;
break;
case '*': result = left * right;
break;
case '/':
if(right == 0){
cout << "Cannot Divide By Zero"<<endl;
result = 0;
}else{
result = left / right;}
break;
default : cout << "Bad operator '" << oper << "'" << endl;
continue; // Start next loop iteration.
}
cout << result << endl << endl;
}
}