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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started