OO Programming with Java


2. Symbolic expressions

The objective here is to model mathematical expression by objects' structure as illustrated below, and then evaluate an expression or print it in various format (postfix, infixe and/or prefix).

Questions
A. To proceed, implement the following model and test it by modeling the preceding example.

B. Transform the model into a parametrized one and use it to model vectorial expressions, e.g. "[1,2]+[3,3]*[1,1]" (evaluated to "[4,5]").

C. Extends the model by introducing the concept of "variable" (e.g. "X"). Then, by using a Map to store the values of the variables (eg. [("X",2),("Y",3)]), define and evaluate the expression "1+X*Y".

answer