View Single Post
  #2 (permalink)  
Old 07-31-2007, 07:48 PM
levent levent is offline
Senior Member
 
Join Date: Dec 2006
Posts: 748
levent is on a distinguished road
You don't need stringtokenizer here. Just read your line as a string. Then create a loop which will go over all characters of the string. Append each character to a temporary stringbuffer (stringbufferLeftExpression) until you find one of the operators. Then save operator type and in a similar way, find the right expression by appending characters to a temporary stringbuffer (stringbufferRightExpression). When you find the next operator, apply previous operation on stringbufferLeftExpression and stringbufferRightExpression and save the result to stringbufferLeftExpression. This loop goes like this until whole operation is finished.

I try to explaing it without writing the code. Try it yourself if you understand it. If something is unclear let me know.
Reply With Quote