I have a multidimension arrayList and I ask the user for a formula and than I evaluate it. The problem is that I get user input like this:
((a1+a2)/12)*a3
the problem is that a1 and a2 and a3 refer to columns and I have to evaluate it to a certain value to it and I am totally lost on how to approach this problem any advice or guidance would be great. Also this calculate value has to update every time the value in any of the columns Update. The thing is the formula isn’t hard coded.
A possibility is write a sort of parser. It’s better to use a binary tree structure to represent an expression, rather than a list.
Each non-leaf node is an operation and every leaf is operand.