Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer in java Intellij programming language. the goal for this assignment is to create software for a stack as an object. You need to

please answer in java Intellij programming language. the goal for this assignment is to create software for a stack as an object.

You need to create a simple stack class and then test it by using the stack to reverse the items in an array of Strings. You should create an array-based stack class with push and pop methods, similar to what is described in the reading assignment. The datatype for this stack will be String. Your stack class should implement a stack of Strings. (Each item in the stack will be a String holding the name of a city.) You should create a String array in your main() method that contains the list of cities shown below in order. This is an array of source data -- it is not the array in your stack class, The list represents the path to get from Philadelphia to Chicago. You can use an explicit array declaration to do this, such as:

String cities[] = { "Philadelphia, PA", "Harrisburg, PA", "Pittsburg, PA", "Cleveland, OH", "Toledo, OH", "Gary, IN", "Chicago, IL" };

image text in transcribed

Our task is to test the Stack Class by reversing the order to get the path from Chicago to Philadelphia. Remember, this isn't about the path; we are just using this problem to test our stack class. After you create the Stack Class, your main method in the project class should : instantiate the String array of cities. This array is not part of your stack software. It is data in the main() method to be used to test your Stack class. instantiate a String stack using your Stack class. iterate the source data array and print the cities in order, showing the path from Philadelphia to Chicago. Make sure your printout is easy to read. iterate the data source array again, and push each city name onto the stack one at a time. using a loop that continues until the stack is empty, pop each city name from the stack and put it back into the data source array starting in order at position 0 in the data source array. The result should be the same data that you started with, but in reverse order. Iterate the source data array again, printing the cities in the order in which they are in the array. If your software works correctly, then the cities array will be in reverse order the second time that it is printed, showing the path from Chicago to Philadelphia. You should submit your software project. Remember to start with documentation -- using a documentation-first design strategy for all of your software.

Computer Science 211 Data Structures Spring 2021 Semester Week 5 Programming Assignment - Stacks due Tuesday February 23 2021 Community College of Philadelphia Computer Science Your task is to create software for a stack as an object. You need to create a simple stack class and then test it by using the stack to reverse the items in an array of Strings. You should create an array-based stack class with push and pop methods, similar to what is described in the reading assignment. The datatype for this stack will be String. Your stack class should implement a stack of Strings. (Each item in the stack will be a String holding the name of a city.) You should create a String array in your main() method that contains the list of cities shown below in order. This is an array of source data -- it is not the array in your stack class, The list represents the path to get from Philadelphia to Chicago. You can use an explicit array declaration to do this, such as: String cities[] = { "Philadelphia, PA", "Harrisburg, PA", "Pittsburg, PA", "Cleveland, OH", "Toledo, OH", "Gary, IN", "Chicago, IL" }; Our task is to test the Stack Class by reversing the order to get the path from Chicago to Philadelphia. Remember, this isn't about the path; we are just using this problem to test our stack class. After you create the Stack Class, your main method in the project class should: 1. instantiate the String array of cities. This array is not part of your stack software. It is data in the main() method to be used to test your Stack class. 2. instantiate a String stack using your Stack class. 3. iterate the source data array and print the cities in order, showing the path from Philadelphia to Chicago. Make sure your printout is easy to read. 4. iterate the data source array again, and push each city name onto the stack one at a time. 5. using a loop that continues until the stack is empty, pop each city name from the stack and put it back into the data source array starting in order at position 0 in the data source array. The result should be the same data that you started with, but in reverse order. 6. Iterate the source data array again, printing the cities in the order in which they are in the array, If your software works correctly, then the cities array will be in reverse order the second time that it is printed, showing the path from Chicago to Philadelphia. You should submit your software project. Remember to start with documentation -- using a documentation-first design strategy for all of your software

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions