Question
Learning Activity-02: Converting mathematical expressions from Infix to Postfix Convert infix expressions to postfix expressions Assume: expressions consists of only spaces (a single space in
Learning Activity-02:
Converting mathematical expressions from Infix to Postfix
Convert infix expressions to postfix expressions
Assume:
expressions consists of only spaces (a single space in between two elements), operands (can be single character/digit or multi-character/ multi-digit), and operators (consider only +, -, *, /, %).
space is a delimiter character (you may use string split method assuming this delimiter character)
all operands that are identifiers begin with a letter or underscore
all operands that are numbers begin with a digit
You may use the algorithm in this document and the starter code provided in the d2l course webpage.
What you need to do:
Implement the InfixToPostfix class in the way you want however, you must have a method with the Signature: public String getInfixToPostfix(String infix).
The above method should return the postfix string equivalent to the given input string infix.
You may or may not modify the main method.
Your InfixToPostfix class must pass the provided test cases.
You must not modify the test class!
Marking Criteria
Name | Description | Max Points |
Functionality | The method gives postfix expression correctly. The method works for all test case inputs. | 60% |
Efficient implementation | Algorithmic steps are followed efficiently. | 20% |
Readability and comments | Your program is easy to read/understand. It has frequent comments for explaining complex statements/ methods/ important sections. | 20% |
Total |
| 100% |
Example:
convert
w 5.1 / sum * 2
to its postfix form
w 5.1 sum / 2 * -
Visual Algorithm with Steps:
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