Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

List three content theories of motivation and two process theories.

Answered: 1 week ago

Question

Discuss all branches of science

Answered: 1 week ago