Ok, I am having two issues with this program, and since I am new to the forum, yes, I am a beginner so I am sure the error is so common it makes you want to cry seeing it again, haha. Anyway, the program is supposed to keep working with the numbers and math operators you input. The math is fine (after some simple mistakes were corrected) but even when you type in a valid operator and number, the ELSE statement is still run.
Likewise, the loop does not terminate on X or x as I thought I had designed it to.
double tot, num;
char oper;
tot = 0;
cout << "Current total is " << tot <<endl;
do
{
cout << "Enter and operation: + - * / (or enter X to exit): "; cin >> oper;
if (oper == '+')
{
cout << "Enter a number: "; cin >> num;
tot = tot + num;
cout << "Current total is " << tot << endl;
}
if (oper == '-')
{
cout << "Enter a number: "; cin >> num;
tot = tot - num;
cout << "Current total is " << tot << endl;
}
if (oper == '*')
{
cout << "Enter a number: "; cin >> num;
tot = tot * num;
cout << "Current total is " << tot << endl;
}
if (oper == '/')
{
cout << "Enter a number: "; cin >> num;
tot = tot / num;
cout << "Current total is " << tot << endl;
}
else if (oper != 'X' || oper != 'x' || oper == '/' || oper == '*' || oper == '-' || oper == '+') cout << "Enter a valid number." << endl;
}
while (oper != 'X' || oper != 'x');