Question: I am currently learning about Stacks in my Java computer science class, I am not entirely sure how I am supposed to complete this lab.

I am currently learning about Stacks in my Java computer science class, I am not entirely sure how I am supposed to complete this lab. Any help is greatly appreciated, and I will leave a positive review!

I am currently learning about Stacks in my Java computer science class,PostFix:

import java.util.Stack; import java.util.Scanner; import static java.lang.System.*; public class PostFix { private Stack stack; private String expression; public PostFix() { } public PostFix(String exp) { } public void setExpression(String exp) { } public double calc(double one, double two, char op) { return 0.0; } public void solve() { } //add a toString }

PostFixRunner:

import java.util.Stack; import java.util.Scanner; import static java.lang.System.*; public class PostFixRunner { public static void main ( String[] args ) { PostFix test = new PostFix("2 7 + 1 2 + +"); test.solve(); System.out.println(test); test.setExpression("1 2 3 4 + + +"); test.solve(); System.out.println(test); test.setExpression("9 3 * 8 / 4 +"); test.solve(); System.out.println(test); test.setExpression("3 3 + 7 * 9 2 / +"); test.solve(); System.out.println(test); test.setExpression("9 3 / 2 * 7 9 * + 4 -"); test.solve(); System.out.println(test); test.setExpression("5 5 + 2 * 4 / 9 +"); test.solve(); System.out.println(test); } }

A+ Computer Science POST FIX SOLVER Lab Goal : This lab was designed to teach you more about stacks. Lab Description : Take a postfix expression and solve it. All numbers will be in the range 0 to 9. Standard infix expression 7 + 8 - 2 Standard postfix expression 7 8 + 2 - Files Needed :: Postfix.java PostfixRunner.java algorithm help Sample Data : 27 + 1 2 + + 1 2 3 4 + + + 9 3 * 8/4 + 33 + 7 * 92 / + 93 / 2 * 7 9 * + 5 5 + 2 * 4 / 9 + 4 while there are more values in the original expression { get the next value if the value is a number push the number onto the stack else if the value is an operator pop 2 numbers from the stack use the operator to evaluate the 2 numbers push the resulting number onto the stack } return the top value from the stack Sample Output : 27 + 1 2 + + = 12.0 1 2 3 4 + + + = 10.0 93 * 8/4 + = 7.375 33 + 7 * 92 / + = 46.5 9 3 / 2 * 7 9 * + 4 - = 65.0 5 5 + 2 * 4/9 + = 14.0

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!