im not exactly sure where to start and i dont really understand it. i dont know if im right, but i tried to understand the question by following the sample inputs. For example, the first sample input, (1 5 9 + 8 – + ), you take leave the 1 alone for now. Next, you take the first operand ( +) and add 5 and 9 together which equals 14. Then you take the next operand (-) and subtract 14 and 8 which is 6. Then you take the last operand the ( +) and add 6 and 1 together which is 7.
let me know if i have the basic idea..
should i use the indexOf() method to call the operands ?i dont know what to do.. im really confused !
One suggestion. When you take the first operand and do the math then use String.replace() in order to put the result where it was:
1 5 9 + 8 – + -->
1 14 8 – +