Question: Help Nedded ASAP! Please. In this project, you will be using stacks to parse/evaluate arithmetic expressions. To parse infix exprssions, use the Shunting Yard algorithm
Help Nedded ASAP! Please.



In this project, you will be using stacks to parse/evaluate arithmetic expressions. To parse infix exprssions, use the Shunting Yard algorithm of Dijkstra (discussed in class) Wikipedia page: https://en.wikipedia.org/wiki/Shunting-yard algorithm Algorithms to evaluate postfix expressions and expression trees were discussed in class Use Stack or ArrayDeque from the Java library for the stacks. Do not code your own stack Starter code Expression.java is provided. Add additional fields, methods, clsses as needed Do not change the name of the class or signatures of public methods The following methods need to be completed. No error checking is required. If the expressions passed are valid, then the methods should work correctly Given invalid expressions, your program can return wrong values, print error messages, or throw exceptions Method to convert String to a Token: The string holds exactly one token, with no extra spaces before or after the token Possible tokens are: Operators: PLUS ( " +"), TIMES ("*"), MINUS ("-"), DIV ("/"), MOD ("%"), POWER ("^") Parentheses: OPEN (" ("), CLOSE (")") Number: NUMBER (any valid string that represents an integer) Assume that if a token is not an operator or a parenthesis, then it is a number. Use Long.parseLong (tok) to convert string to long. Signature: static Token getToken(String tok) 1 Tokens have a field "priority" that can be used to store precedence of operators during parsing. Precedence: {^} > {*, /, %} > {+, -). Assume that all operators are left associative. Assign your own values to priority of tokens Field "number" is used to store the value of NUMBER token. A token "NIL" is defined for internal use and it does not correspond to any token in the expressions.It is a convenient token to mark bottom of stack. Method to convert an iniix expression given as a 11st of tokens into an expression tree: Given an infix expression as a list of tokens, return its corresponding expression tree. Signature: public static Expression infixToExpression(List
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
