Question: JAVA LANGUAGE Grab an expression from the user and evaluate it. The expression can contain +-/*( ) The expression will not contain any spaces. All

JAVA LANGUAGE Grab an expression from the user and evaluate it. The expression can contain +-/*( )

The expression will not contain any spaces. All the numbers will be single digit (between 0 and 9). No error checking is necessary.

Example:

Give me an expression: 2*(6-3)

What will be displayed on the screen

Postfix expression: 263-*

Answer: 6

Do not use any of the built-in stack functions. Convert to postfix and evaluate. DIRECTIONS: JAVA LANGUAGE Grab an expression from the user and evaluate it. Theexpression can contain +-/*( ) The expression will not contain any spaces.All the numbers will be single digit (between 0 and 9). No

9) What conditions do I need to consider for converting infix to postfix A: There are 4 conditions: open parentheses, close parentheses, numbers and operators 10) What does the main method in the Driver class look like A: Grab an infix expression from the user, call the convert method in the Postfix class and grab its return value which is a postfix expression. Display postfix expression Call the evaluate method in the Postfix class with the converted postfix expression as its argument and return the result Display the result 11) How do I turn in my assignment A: Everything should be in a single file. There should be only one public class (Driver) 12) Can I create more classes than what has been stated? A: By all means. You can create more classes 13) Can I use the generics feature which works like templates in Java to avoid having to create 2 node classes since the only difference is one has a value of type int and the other is of type char A: Yes, you can. 1. Does the pop function have to return the whole node that is popped from the stack or just the value that the node holds? A: It is up to you. Either way is fine. 2. Since the evaluation process only deals with one operator at a time, pushing the evaluated value from the expression of the two operands and operator, is the precedence of the operator still relevant? And if it is still relevant, how do we take the precedence into consideration when evaluating the two operands at hand? There is no operator in the stack to compare the current operator to. A: When you get to evaluation, at this point your expression is in postfix format which means that you no longer have to worry about the precedence. That is the advantage of converting your expression to postfix format. 3. Can we use the isdigit() function instead of a switch statement to check for integers vs operators? A: Yes Can we use the stoi) and to_string) functions to convert a value from string to integer and vice versa? A: Yes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!