Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

programin with java Create an application that can evaluate an infixed expression by using the Generic Stack structure then print out the result in the

programin with java

Create an application that can evaluate an infixed expression by using the Generic Stack structure then print out the result in the following format:

For example

Read an infixed expression,

(1 + 2) * 4 3

The output should be: (1 + 2) * 4 3 = 9

The application should allow users to choose where to read the expression: from the keyboard or from a file (file stores one expression on one line)

After finishing one expression, the application should loop back to allow users to select the source to read the expression from then continue to do until the users want to exit

Add a class GenericStack that can apply for any data type. You can use the code of GenericStack in the book page 167 for your reference

image text in transcribed

Add the driver class named InfixedExpression that has 5 user defined functions, one function of phase 1, one function for phase 2, one function of process One Operation, one function for procesOneExpression and one function for display output

1. public class GenericStack 2. private TI data; private int top private int size; public GenericStack) { top=-1; size data 100; (t[]) new Object [100]; 10 public GenericStack (int n) 11, { top=-1; 12 13 size n; data (T[]) new Object [n]; 15. public boolean push(T newNode) 16. GenericNode node (GenericNode) newNode; if(top size - 1) return false; overflow error else 19 20 21. { top top + 1; data[top] (T) node . deepcopy(); return true; push operation successful 23 24. 25 public T pop) 26. int topLocation; if ( top 1 ) -# return null; underf1ow error else 28 30 32 { topLocation=top; top = top . 1; return datal topLocation]; 34 35. 36, public void showAl1() { for (int i = top; i >= 0; i..) System.out.println(data[il.tostring)); 38. / end of showAll method 39.F end of class Genericstack 1. public class GenericStack 2. private TI data; private int top private int size; public GenericStack) { top=-1; size data 100; (t[]) new Object [100]; 10 public GenericStack (int n) 11, { top=-1; 12 13 size n; data (T[]) new Object [n]; 15. public boolean push(T newNode) 16. GenericNode node (GenericNode) newNode; if(top size - 1) return false; overflow error else 19 20 21. { top top + 1; data[top] (T) node . deepcopy(); return true; push operation successful 23 24. 25 public T pop) 26. int topLocation; if ( top 1 ) -# return null; underf1ow error else 28 30 32 { topLocation=top; top = top . 1; return datal topLocation]; 34 35. 36, public void showAl1() { for (int i = top; i >= 0; i..) System.out.println(data[il.tostring)); 38. / end of showAll method 39.F end of class Genericstack

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 For Advanced Applications 17th International Conference Dasfaa 2012 Busan South Korea April 2012 Proceedings Part 1 Lncs 7238

Authors: Sang-goo Lee ,Zhiyong Peng ,Xiaofang Zhou ,Yang-Sae Moon ,Rainer Unland ,Jaesoo Yoo

2012 Edition

364229037X, 978-3642290374

More Books

Students also viewed these Databases questions

Question

Prepare a constructive performance appraisal.

Answered: 1 week ago

Question

List the advantages of correct report formatting.

Answered: 1 week ago