Problem

The infix-to-postfix conversion algorithm described in this chapter assumes single digit o...

The infix-to-postfix conversion algorithm described in this chapter assumes single digit operands and that the given infix expression is syntactically correct. Repeat Programming Problem 6 with the following enhancements. If the expression has one of the errors mentioned, print out an appropriate error message, and where possible, indicate where the error occurred in the expression. If the expression is syntactically correct, evaluate the expression.

a. Allow for any type of spacing between operands, operators, and parentheses.

b. Allow for multi-digit integer operands. Even better, allow for multi-digit operands with a decimal point.

c. The algorithms in the text assume that the given infix expression is syntactically correct. Watch for errors in the infix expression. Here are some examples:

i.a+4 (Illegal character a)


ii.4+53 (Space between 5 and 3, a missing operator)


iii.4 + *5 -2 (Missing operand)


iv.)2+3( (Improperly nested parenthesis)


v.(2 +3) *5) (Mismatched parentheses-right or left)


If an error is detected during the methodconvertPostfix, it should return false, but first print a message diat identifies the error and, when possible, indicate where the error occurred in the expression. If the expression is not successfully converted, a call toevaluate orgetPostfix should tiirowIllegalStateException.

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 7
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