I'm trying to create a calculator application wherein the user types an equation into a text box, which the application is then supposed to solve for them. I'm unsure how to implement this though. I want to use + for addition, - for subtraction, * for multiplication, and / for division. Is there a way I can convert the text inputted into a field into an equation that the application answers?
Asked
Active
Viewed 96 times
0
-
7We would write a [Parser](https://en.wikipedia.org/wiki/Parsing) to transform the input in a representation that can be evaluated programmatically (e.g. an Abstract Syntax Tree, or AST for short). – Turing85 Jun 22 '21 at 20:48
-
1https://en.wikipedia.org/wiki/Shunting-yard_algorithm – OneCricketeer Jun 22 '21 at 20:58
-
google `expression evaluation` – Spektre Jun 23 '21 at 09:04