Skip to main content

java collections programing help

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2011-06-24

How to evaluate 1+2*3+4/2-2 arthematic expression by taking input as a string using operator priority

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-07-02

Google: "parsing arithmetic expressions"

Firstly you would need to split the string into meaningful lexems (numbers, signs). This could be done in more than one way. However it is not complex problem.

Secondly you need to process them, applying arithmetic rules. You would find that priority is often managed via recursion according to backus-naur rules for your case, or via translating to Reverse Polish Notation and then simply evaluating it.

P.S. Why, by the way, have you chosen such obscure title for your question?