Assignment 4

Due date: Thursday, Octomber 31, in the lab.
NOTES:
This assignment requires JAVA object oriented techniques. You will practice the Stack data structure.

Problem description

Write a program EQ-Calculator according to the following requirements:

Requirements:

  1. The input of EQ-Calculator is an arithmetic expression in the infix notation. The aritmetic expression can have paranthesis, such as (), {} and [].
  2. The aritmetic expression may contain variables. If variables are present EQ-Calculator must identify them and prompt the user to input values.
  3. EQ-Calculator must first check that the expression has balanced paranthesis regardless of the presence of variables in the expression. If the expression is not balanced then your program must output and error message and prompt the user to input another expression.
  4. If the expression is correct, then EQ-CalculatorĀ  must convert the original expression into the postfix notation (hint: no paranthesis are present in the postfix notation). Diplay your expression in the postfix notation.
  5. Evaluate the expression using its postfix representation. Display each step of the evaluation algorithm. If there are any errors (stack overflow or underflow, or a bad token), simply output "error" to the standard output.
  6. EQ-Calculator must support the four basic operators +, -, *, and /.
  7. In the input, you may assume that all tokens are separated by spaces.
  8. Bonus points


  9. (1 points). If the brackets do NOT match, report the character number where it discovered the error (starting at 0 from the left) and the incorrect character it
    found there. For example, for the input string:

    2{3(x]5}y

    the output from the program should be:

    Error: ‘]’ at position 5

  10. (1 points): Allow your expression to include unary operators, such as ++ and --
  11. .
Bonus Points: Develop a user interface for the project.