Okay Ive made a bunch of single use calculator programs (one for addition, subtraction, mutiplication, and division).
Addition Code
#include <iostream>
using namespace std;
int main()
{
cout << "Please enter 2 numbers to be added ";
int a;
int b;
cin >> a;
cout << "\n num1: " << a << endl;
cin >> b;
cout << " \n num2: " << b << endl;
cout << " \n a + b = " << a + b << endl;
cout << "Press the enter key to exit";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin.get();
return 0;
}
Subtraction
// Division Calculator
#include <iostream>
using namespace std;
int main()
{
cout << "Please enter two numbers to be divided: ";
int a;
int b;
cin >> a;
cout << "\n num1: " << a << endl;
cin >> b;
cout << "\n num2: " << b << endl;
cout << "\n a / b = " << a / b << endl;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin.get();
return 0;
}
Multiplication
//Multiplication Calculator
#include <iostream>
using namespace std;
int main()
{
cout << "Please enter two numbers to be multiplied: ";
int a;
int b;
cin >> a;
cout << "\n num1: " << a << endl;
cin >> b;
cout << "\n num2: " << b << endl;
cout << "\n a x b = " << a * b << endl;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin.get();
return 0;
}
Division
// Subtraction Calculator
#include <iostream>
using namespace std;
int main()
{
cout << "Please enter 2 numbers to be subtractred";
int a;
int b;
cin >> a;
cout << "\n num1: " << a << endl;
cin >> b;
cout << "\n num2: " << b << endl;
cout << "\n a - b = " << a - b << endl;
cout << "Press the enter key to exit";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin.get();
return 0;
}
My question is how do I combine these all into one program. Id ask please enter + - * or /. And then make an if statement ....if "symbol" ==x multiply. Is that the right logic or is there a much easier way to do this. And how would I right that if statement. Thanks youve helped me a lot lately guys. -Nick