Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a stack class named MyStack that stores generics with the methods shown below. Write a test program that thoroughly tests your stack implementation. void

Create a stack class named MyStack that stores generics with the methods shown below. Write a test program that thoroughly tests your stack implementation.

void push(E item)

push item onto top of stack

E peek()

return item on top of stack

E pop()

return item on top of stack and remove it from the stack

boolean isEmpty()

returns whether or not stack is empty

Once the stack is working, create a class EvalPostfix that receives a postfix expression in String format, uses the MyStack class to evaluate the expression, and returns the resulting value. You may assume that all operands and operators (+ - * /) will be separated by a single space. Operands will be integers and may contain several digits. The class will require the following functions to be implemented:

EvalPostfix(String post)

constructor that sets the attribute containing the postfix string to be evaluated

int eval()

returns the result of the postfix expression

Write a test program named Prog5 that gets a postfix expression from the keyboard, uses EvalPostfix to evaluate the expression, and displays the result.

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

In Exercise 40 what is the

Answered: 1 week ago

Question

to encourage a drive for change by developing new ideas;

Answered: 1 week ago

Question

4 What are the alternatives to the competences approach?

Answered: 1 week ago