Problem

Algebraic expressions are character strings, but since string is a final class, you cannot...

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.

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 9
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT