hello everyone,
i need help with my homework. i will appreciate your knowledge and help with my problem i have. i cannot get my program to work. i need to ask a user to input an operator and two operands. example "+, -, *, or /" and two numbers.
ex] *, 5, 5,
output 5 * 5 = 25
the following is what i have so far.
issues:
in function void ProcessAndDisplay(int firstNumber, int secondNumber, int total)
'operators': undeclared identifier
thank you for you help
-------------------------------------------------------
void GetData(char& operand, int& firstNumber, int& secondNumber)
{
cout << "Please type one of the following operators and press ENTER ( *, /, -, + ) ";
cin >> operand;
cout << endl;
cout << "Type a number and press enter ==> ";
cin >> firstNumber;
cout << "Type another number and press enter ==> ";
cin >> secondNumber;
cout << endl;
}
void ProcessAndDisplay(int firstNumber, int secondNumber, int total)
{
if (operators == '+')
{
total = firstNumber + secondNumber;
cout << firstNumber << " + " << secondNumber << " = " << total << endl;
}
else if (operators == '-')
{
total = firstNumber - secondNumber;
cout << firstNumber << " - " << secondNumber << " = " << total << endl;
}
else if (operators == '*')
{
total = firstNumber * secondNumber;
cout << firstNumber << " * " << secondNumber << " = " << total << endl;
}
else if (operators == '/')
{
total = firstNumber / secondNumber;
cout << firstNumber << " / " << secondNumber << " = " << total << endl;
}
else
cout << "Operator must be one of the following ( *, /, -, + )." << endl;
}
The error is telling you exactly what it looks like it is: not a single place in ProcessAndDisplay is there any definition for the (variable?) called "operators".