Assignment Four
For this
assignment, you are to generate an expression tree (see page 380-395 in the
text) from an algebraic expression. The operators are the binary operators +,
-, *, / and ^ (exponentiation) and the parenthesis operators, ( and ). The
operands are non-negative integers and variables made up of single letters
only. Output the prefix notation, the fully parenthesized infix notation of the
expression, the postfix notation, and sample assembly code of the expression.
The assembly code statements are:
Load R0, operand
Add R0, operand
Sub R0, operand
Mul R0, operand
Div R0, operand
Pow R0, operand
Sto R0, operand
The
operand can be a single letter variable or an integer.
The algebraic
expression to expression tree algorithm will be discussed in class.
To do this you
are to create a class ExpressionTree. The Expression Tree class should have a
BinaryTree as a data member. See ExpressionTreeSkeleton.txt
for a guide. Use BinaryTree.java
for the BinaryTree class.
Click here
for sample output from my program. Your output should be similar.
You can use the
JOptionPane class to input the expression and output the results.
The user should
be able to input several expressions without re-executing the program.
This
assignment is due on November 8th at class time. No assignments will
be accepted after that time and there will be a quiz.