Algebraic expressions are character strings, but since string is a final class, you cannot derive a class of expressions from String. Instead, define an abstract class Expression that can be the basis of other classes of algebraic expressions. Provide methods such as characterAt, isOperator, and isldentifier. Next design and implement a class InfixExpression derived from the class Expression.
Programming Problem of Chapter describes a grammar and a recognition algorithm for infix algebraic expressions. That grammar makes left-to-right association illegal when consecutive operators have the same precedence. Thus, a/(b*c) is illegal, but both a/(b*c) and (a/b)*c are legal.
Programming Problem of Chapter describes an algorithm to evaluate an infix expression that is syntactically correct by using two stacks.
Include in the class InfixExpression an isLegal method—based on the recognition algorithm given in Chapter—and an evaluate method—based on the evaluation algorithm given in Chapter. Use one of the ADT stack implementations presented hi Chapter.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.