Infix to postfix using queue
Hey guys, im trying to write a single class program that uses a Queue to change an infix expression to postfix expression. The infix expression will be a string that will be input by the user. Before I start coding, I want to make sure I have all the possible methods that I will need to complete the program. The methods that I believe I will need are listed below. It would be great if you guys could suggest some methods to add or take out some of the ones I mentioned. Thanks in advance.
1. Main: ultimately runs program and gathers user input
2. checkParens: checks to make sure the parentheses in the postfix are balanced
3. checkOperans: checks to make sure there are sufficient/insufficient operands in the user input postfix
4. checkOperators: checks to make sure there are sufficient/insufficient operators in the user input postfix
Re: Infix to postfix using queue
Re: Infix to postfix using queue
Depending upon how you code the conversion you may not need all the check methods. For example once the conversion has complete and the stack is not empty then you now that the original infix equation was invalid. Also, as you are converting the infix equation you know you must read operand:operator:operand:operator:operand etc. So if you try reading an operand but get an operator (or vice versa) you know the equation is invalid.