Could not match operator.
A simple calculator, but yet it keeps saying could for the first if statement not match operator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double num1;
double num2;
double num3;
double num4;
string symbol;
char again;
do
{
cout << "Enter Number:\n";
cin >> num1;
cout << "Enter Number:\n";
cin >> num2;
cout << "Enter first letter in math expression\n";
cin >> symbol;
if (symbol == 'a')
num3 = (num1 + num2);
cout << num1 << " + " << num2 << " = " << num3 << endl;
if (symbol == 's')
{ num4 = (num1 - num2);
cout << num1 << " - " << num2 << " = " << num3 << endl;
}
cout << "Do you want to play again <y/n>\n";
cin >> again;
}while (again == 'y');
system("pause");
return 0;
}
|
Last edited on
try changing string symbol to char symbol.
Or change all comparison to string instead of char.
symbol == "a"
symbol == "s"
Topic archived. No new replies allowed.