HW4: Expression Trees Solution



For this assignment you will write a program that reads postfix expression from the user, one per line, terminating when the user enters a blank line.

(Follow the same input pattern as HW3)

For each postfix expression, due the following:

  1. Build an expression tree supporting +-*/

  1. Print out the equivalent infix expression, in heavily parenthesesed form.

  1. Print out the numeric value of the expression.

10pt Bonus: support variables in expressions, introducing an = (assignment) operator to intro-duce/initialize new variables. Save variables between evaluations.

I am here to give as much help as needed!

Turn in. . .

Make sure your main method is in a class called ETreeDriver. Do not print any prompts or values other than the infix expression and resulting value.

Do not worry about invalid expressions.

Java files with your name in comments at the top of each.

Code must compile to be worth points.

Assignment must be submitted by the due date to be eligible for bonus points.

error: Content is protected !!