I am working on a c++ assignment , I figure out how to determain the numbers , but what about the operation in the string , for example 1-2 or 1+2
right now my program would make the following
operand1=1
operand2=2
then somehow i need to determain the minus or the plus in between to make that operation.
Hope to find help on how to determine that , is theres a way to cast that string + or - to convert it to an operation .
I actually like rambo's, but there are a couple of things that could be added/improved.
First, the concept of operator precedence doesn't exist. E.g. 1+2*3 outputs 9 instead of 7.
A possible solution to this is to evaluate the expression in two steps. During the first step,
perform multiplications and divisions and during the second, additions and subtractions.
That is, input like this -> 1+2*5-3*4+6 should first be turned into 1+10-12+6 and then into 5.