Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CMSC 350 Project 1 (Substitute) The first programming project involves writing a program that conwerts preexpeessions to postfix and postfix expressions to prefix Custornary infix
CMSC 350 Project 1 (Substitute) The first programming project involves writing a program that conwerts preexpeessions to postfix and postfix expressions to prefix Custornary infix expression place the operator between the two operands in ? pre expression, the operator comes before the two operands in postfix expression?comes fter them. One benefit of preftx and postfs expressions is that they never require parentheses nor rules regarding precedence or The program for thi project shoud consist of three dasses. The main class should areate a GuI that allows the user to input an expression in eithar prefix or postfix and conwart it to posfix or prefix, respectively. The Gui should look as follows the same GUI is shown for each of the two cowersons: Expresson Coverter The GUI must be generated by code that you write. You may mot use a drag-and-drop GUl generator The second class should contain the code to perform the conversions The pseudocode for prefix to postfox, which requires two stacks, is shown below tokenize the string containing the prefix expression while thee are oze tokens push the token onto an auxiliary stack if it is not a space while the auxi11ary stack 1s not enpty get the next token puah it onto the opezand stack la it is an apezator pop two operands ofs of the operand stack create a string with the two ap randa Eallawed by the aperato push that string onto the operand stack pop the posttix expression off the operand stack The pseudocode for the postfix to preftx conwersion, which requires only one stack, is shown below takenize the string eontaining the paatix xpreasion vhile there get the next token if it 1sspace .13. if it is an #Ps:and la it is an apezator skip it push it onto the operand stack pop tvo operands oEE oE the operand atack create a string with the operator followed by the two operand:s uah that atring cnto the aperand atack pap the prfixexpian aff the opezand staek Be sure to add any additional methods naedad to eliminate any dupication of code The input expressions should not be required to contain spaces between tokens unless they are consecutive operands. The output expressions shold always have a space between al symbols. The third class should be a custom checked exception SyntaxError. The exception should be thrown by the methods that perform the comversions an empty stack is ever popped or the stack is not empty once the conversion is complete. The exception should ba caught in the main class, where a JOptionPane window should be displayed containing an error messag CMSC 350 Project 1 (Substitute) The first programming project involves writing a program that conwerts preexpeessions to postfix and postfix expressions to prefix Custornary infix expression place the operator between the two operands in ? pre expression, the operator comes before the two operands in postfix expression?comes fter them. One benefit of preftx and postfs expressions is that they never require parentheses nor rules regarding precedence or The program for thi project shoud consist of three dasses. The main class should areate a GuI that allows the user to input an expression in eithar prefix or postfix and conwart it to posfix or prefix, respectively. The Gui should look as follows the same GUI is shown for each of the two cowersons: Expresson Coverter The GUI must be generated by code that you write. You may mot use a drag-and-drop GUl generator The second class should contain the code to perform the conversions The pseudocode for prefix to postfox, which requires two stacks, is shown below tokenize the string containing the prefix expression while thee are oze tokens push the token onto an auxiliary stack if it is not a space while the auxi11ary stack 1s not enpty get the next token puah it onto the opezand stack la it is an apezator pop two operands ofs of the operand stack create a string with the two ap randa Eallawed by the aperato push that string onto the operand stack pop the posttix expression off the operand stack The pseudocode for the postfix to preftx conwersion, which requires only one stack, is shown below takenize the string eontaining the paatix xpreasion vhile there get the next token if it 1sspace .13. if it is an #Ps:and la it is an apezator skip it push it onto the operand stack pop tvo operands oEE oE the operand atack create a string with the operator followed by the two operand:s uah that atring cnto the aperand atack pap the prfixexpian aff the opezand staek Be sure to add any additional methods naedad to eliminate any dupication of code The input expressions should not be required to contain spaces between tokens unless they are consecutive operands. The output expressions shold always have a space between al symbols. The third class should be a custom checked exception SyntaxError. The exception should be thrown by the methods that perform the comversions an empty stack is ever popped or the stack is not empty once the conversion is complete. The exception should ba caught in the main class, where a JOptionPane window should be displayed containing an error messag
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