while( cin >> numb1 >> sign >> numb2 ) // If nnumb1 of the numb2o integers equal to EOF, enter the loop.
{
// Determine the sum of the operatinumb1.
switch( sign ) // switch loop for the char.
{
case '+':
sum = numb1 + numb2;
cout << numb1 << sign << numb2 << " = " << endl << sum << endl << endl;
break; // exit switch loop
default: // To catch all other characters.
cout << "\nBad Operator. '" << sign << "'" << endl;
cout << "Please enter a new operator or EOF to exit\n";
break; // exit switch loop
} // end switch loop
} // end while loop
} // end functinumb1 candoit
}; // end class calculator
int main()
{
Calculator doit; // Creating an object from the class Calculator.
doit.candoit(); // call the functinumb1 *candoit* from the object created *doit* under the class name Calculator.
return 0; // To indicate successfully terminatinumb1.
I'm starting to realize that I'm completely lost. These were my instructions.
Your program should use a end of file loop to read the two floats (operands) and a character operator ( + , - , * , / ).
For each line of input your main function should call one of four(4) value-returning functions (e.g. add, subtr, mult, divide) each designed to perform the indicated operation on the two floats. Each function performs the appropriate operation and returns the result to the main function.
The main function must display the operands, the operator and the result.
Ok, so first things first this isn't Java so functions do not have to be tied to classes that simplifies things a little for you.
To keep it simple we'll use your main function to do the reading and storing of the characters. So an end of file loop looks some thing like this: while(!InputFile.eof()){...} so let's start by putting that into your code.
EDIT: Also delete this Class that you have going, your instructions didn't ask for it and we won't be needing it. You can start a new thread to ask about classes if you're still interested later.