Hey I am coding a simple calculator at the moment in C++. I would love some help with.
I am coding in console and I wrote this to start with:
cout << "Would you like to calculate PLUS or MINUS? \n";
Now I want to do so if they would write plus it would do + and else -
I am a total noob since I started today and this is how my code looks like (it does not work)
Code:
#include <iostream>
using namespace std;
int main()
{
int a;
int b;
int sum;
int sum2;
cout << "Would you like to calculate PLUS or MINUS? \n";
* * * char input = cin.get();
if(input == 'plus')
{
cout << "Enter a number! \n";
cin >> a;
cout << "Enter another number! \n";
cin >> b;
sum = a + b;
cout << "The sum of those numbers is " << sum << endl;
}
else
{
cout << "Enter a number! \n";
cin >> a;
cout << "Enter another number! \n";
cin >> b;
sum2 = a - b;
}
return 0;
}