Question: PostfixEval.java. At first, limit the operations to add, subtract, multiply, and divide. If we require that every token in the input string is separated by

PostfixEval.java. At first, limit the operations to add, subtract, multiply, and divide. If we require that every token in the input string is separated by spaces, e.g., "33 -43 + -55 65 + *", we can evaluate decimals and negatives. Assume that the postfix string is well-formed. Use as test data the postfix expressions below.

this is the assignment

import java.util.*; public class PostfixEval { public static final String operators = "+ - * / % ^ !"; public static void main(String[] args) { System.out.println("Postfix --> Evaluate"); ArrayList postfixExp = new ArrayList(); /* build your list of expressions here */ for( String pf : postfixExp ) { System.out.println(pf + "\t\t" + eval(pf)); } } public static double eval(String pf) { List postfixParts = new ArrayList(Arrays.asList(pf.split(" "))); /* enter your code here */ } public static double eval(double a, double b, String ch) { } public static boolean isOperator(String op) { } } /********************************************** Postfix --> Evaluate 3 4 5 * + 23 3 4 * 5 + 17 10 20 + -6 6 * + -6 3 4 + 5 6 + * 77 3 4 5 + * 2 - 5 / 5 8 1 2 * + 9 3 / - 7 2 3 ^ 8 20 3 % 2 21 3 % 0 22 3 % 1 23 3 % 2 5 ! 120 1 1 1 1 1 + + + + ! 120 *************************************/

That is the shell code we are given. I am reposting this question because someone responded to it saying they will post it later today and check back with them. When I checked back with them they never responded and I am really struggling with the methods in this code especially the eval method. The numbers at the bottom are test cases and results. It is what it should print at the end of all of this.

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!