subject

Create a generic queue class called NotationQueue. NotationQueue will implement the QueueInterface given you. You will be creating NotationQueue from scratch (do not use an internal object derived from the Queue interface from the Java API, from java. util) Create a generic stack class called NotationStack. NotationStack will implement the Stack Interface given you. You will be creating NotationStack from scratch (do not use an internal object of the Stack class from the Java API, java. util)
Utility Class
The Notation class will have a method infixToPostfix to convert infix notation to postfix notation that will take in a string and return a string, a method postfixToInfix to convert postfix notation to infix notation that will take in a string and return a string, and a method to evaluatePostfix to evaluate the postfix expression. It will take in a string and return a double.
In the infixToPostfix method, you MUST use a queue for the internal structure that holds the postfix solution. Then use the toString method of the Queue to return the solution as a string.
For simplicity sake:
operands will be single digit numbers
only the following arithmetic operations will be allowed in an expression:
+ addition
- subtraction
* multiplication
/ division
Exception Classes
Provide the following exception classes:
– occurs when a Notation format is incorrect
StackOverflowException – occurs when a top or pop method is called on an empty stack.
StackUnderflowException – occurs when a push method is called on a full stack.
QueueOverflowException – occurs when a dequeue method is called on an empty queue.
QueueUnderflowException – occurs when a enqueue method is called on a full queue.
GUI Driver (provided)
Initially neither radio button for notation is selected. When a radio button is selected, the Convert button is enabled and the appropriate label and field are visible for the user input.
When the user selects the Convert button, the appropriate label and field with the conversion will be displayed.
When the user selects the Evaluate button, the "answer" to the expression will be displayed.
When the Exit button is selected, the application will close.
ALGORITHMS
Infix expression to postfix expression:
Read the infix expression from left to right and do the following:
If the current character in the infix is a space, ignore it.
If the current character in the infix is a digit, copy it to the postfix solution queue
If the current character in the infix is a left parenthesis, push it onto the stack
If the current character in the infix is an operator,
Pop operators (if there are any) at the top of the stack while they have
equal or higher precedence than the current operator, and insert the
popped operators in postfix solution queue
Push the current character in the infix onto the stack
If the current character in the infix is a right parenthesis
Pop operators from the top of the stack and insert them in postfix solution queue until a left parenthesis is at the top of the stack, if no left parenthesis-throw an error
Pop (and discard) the left parenthesis from the stack
When the infix expression has been read, Pop any remaining operators and insert them in postfix solution queue.
Postfix expression to infix expression:
Read the postfix expression from left to right and to the following:
If the current character in the postfix is a space, ignore it.
If the current character is an operand, push it on the stack
If the current character is an operator,
Pop the top 2 values from the stack. If there are fewer than 2 values throw an error
Create a string with 1st value and then the operator and then the 2nd value.
Encapsulate the resulting string within parenthesis
Push the resulting string back to the stack
When the postfix expression has been read:
If there is only one value in the stack – it is the infix string, if more than one
value, throw an error

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 08:00
The managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an .
Answers: 3
question
Computers and Technology, 24.06.2019 09:50
Create a string list. 2. use console.readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value.tochararray(); if (array.length > = 1) { if (char.islower(array[0])) { array[0] = char.toupper(array[0]); } } for (int i = 1; i < array.length; i++) { if (array[i - 1] == ' ') { if (char.islower(array[i])) { array[i] = char.toupper(array[i]); } } } return new string(array);
Answers: 3
question
Computers and Technology, 24.06.2019 12:30
Do you think media is stereotype ? and why?
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Think of a spreadsheet as a giant calculator spread of paper chart data collector
Answers: 2
You know the right answer?
Create a generic queue class called NotationQueue. NotationQueue will implement the QueueInterface g...
Questions
question
Chemistry, 26.05.2021 03:40
Questions on the website: 13722367