# 算数表达式代写 | Arithmetic Expression Trees Cpt S 321 Homework Assignment

• ALL

Assignment Instructions:

Read each step’s instructions carefully before you write any code.

In this assignment you will finish what you started in the previous homework assignment by
implementing an arithmetic expression parser that builds a tree for an expression. This tree can then be
used for evaluation of the expression. You may want to refer back to the instructions for the first half of
this assignment to make sure that everything was properly implemented there and that you are
following the required naming conventions.

Recall that your expression tree class is implemented in your engine DLL and demoed in this
assignment through a standalone console application that references the DLL. Integration into the
spreadsheet will happen in a future homework assignment.

Requirement Details:

Support parentheses and operators with proper precedence:

● Support the addition and subtraction operators: + and –

o You may assume that all instances of the minus character are for subtraction. In other
words, you don’t have to support negation.

● Support the multiplication and division operators: * and /

● Each operator must be implemented with proper precedence.

● Parentheses must be supported and obeyed. Implementations without support for parentheses
will result in a 50% deduction on all working operators.

Tree Construction:

● Build the expression tree correctly internally.
● You must use the Factory pattern seen in class.

Support for Variables:

● Support correct functionality of variables including multi-character values (like “A2”).

● Variables will start with an alphabet character, upper or lower-case, and be followed by any
number of alphabet characters and numerical digits (0-9).

● As you build the tree, every time you encounter a new variable add it to the dictionary of
variable values with a default value of 0. This will be needed for integration with the
spreadsheet application in a future assignment.

● Variables are stored per-expression, so creating a new expression should clear out the previous
set of variable values. However, all variable values must persist as long as the expression is NOT
being changed.

o Ex: You shouldn’t reset any variables after an evaluation or anything like that

E-mail: vipdue@outlook.com  微信号:vipnxx