Possible Duplicate:
Evaluating a math expression given in string form
Sorry about the long (and also slightly strange :)) title, I couldn't think of a better title for it, but here goes.
I have been making a calculator in Java using a JFrame
which has JButtons
like a real calculator would. As you click the buttons, the calculation appears in a TextArea
. When the 'equals' button is pressed, the whole calculation is taken from the TextArea
and calculated. The problem I'm having is how to actually calculate the answer. This may sound a little weird, but say the calculation I'm getting is 36+45/22
. How would I write the numbers into variables then tell the computer which operations to perform on the variables, and in what order. Can this be done with an infinite number of variables? Is there any way to do this? Thanks for your help.