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

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 oper ands with a decimal point.

c. The algorithm~ in the te>.'t assume that the given infix expression is syntactically correct. Watch for errors in the infix expression. Here are some examples:

If an error is detected during the method convert Postfix, it should return false, but first print a message that identifies the error and, when possible, indicate where the error occurred in the expression. If the expression is not successfully converted, a call to evaluate or get Postfix should throw Illegal St-ate Exception.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!