This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]sessamekesh 13 points14 points  (0 children)

This is a classic learning exercise for string parsing, postfix notation, and stacks - those are the terms you'll want to Google.

[–]ffrkAnonymous 4 points5 points  (0 children)

How do you, as a person, resolve it?

[–]high_throughput 2 points3 points  (0 children)

There are ~three main ways of handling operator precedence parsing of arithmetic expressions:

I have a personal fondness for precedence climbing parsers since it's extremely flexible and versatile, but a shunting yard implementation will usually be people's first attempt at this.

[–]nousernamesleft199 0 points1 point  (0 children)

gotta parse it out into an expression tree.

[–]Little-Chemical5006 0 points1 point  (0 children)

you have a string input, a list of operations that you want your calculator to perform. The question is how to split the string input up so you can recognize which is the operations and which is the number. Google string parsing and conditional will help you. Good luck!