Project2 COP3538 Project 2 – Stacks and Priority Queues Liu University of North Florida 1 Due Date: Friday, 6/14/2019 11:59 PM Turn in: Submit the zipped Eclipse program including at least...

1 answer below »
PFA


Project2 COP3538 Project 2 – Stacks and Priority Queues Liu University of North Florida 1 Due Date: Friday, 6/14/2019 11:59 PM Turn in: Submit the zipped Eclipse program including at least Project2.java, Stack.java, PriorityQueue.java, State.java and States2.csv. The zip file should be named _Project2.zip (for example, Liu_Project2.zip). The program should be well documented in the format of doc comments in Java. Detailed formats are found at http://www.oracle.com/technetwork/articles/java/index-137868.html. Requirements: 1. Reuse your State class from Project 1 (modify it if necessary) 2. Create a class named Stack that will implement a stack of state objects using a singly linked list. Support the following methods. a. Constructor that creates the stack. b. A push method to push a state on the stack c. A pop method to pop a state off the stack and return it. d. A printStack method to print the stack, see the example. e. An isEmpty method that returns true if the stack is empty, false otherwise f. An isFull method that always returns false 3. Create a class named PriorityQueue that implements a priority queue of state objects using an array, based on population, highest population is the highest priority. Support the following methods: a. Constructor that creates the stack array based on a size provided. b. An insert method to insert a state into the queue. c. A remove method to remove a state from the front of the queue and return it. d. A printQueue method to print the queue in priority order, see the example. e. An isEmpty method that returns true if the queue is empty, false otherwise f. An isFull method that returns true if the queue is full, false otherwise 4. Create a class named Project2 that will: a. Read the csv file (States2.csv) of states and create a single stack of state objects containing states from regions South Pacific, West, and Middle Atlantic (discard any states not in those regions, do not modify the input file.). b. Print the stack starting with the top of the stack. c. Create three priority queues, one for each region. d. Pop states off the stack one at a time and insert them into the appropriate priority queue until the stack is empty. e. Print all three priority queues in this order: South Pacific, West, then Middle Atlantic. f. Remove items from the South Pacific priority queue, one at a time, and push them on the stack. g. Remove items from the West priority queue, one at a time, and push them on the stack. COP3538 Project 2 – Stacks and Priority Queues Liu University of North Florida 2 h. Remove items from the Middle Atlantic priority queue, one at a time, and push them on the stack. i. Print the stack on last time, then exit the program The queues and the stack should be printed in the following format: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Florida Tallahassee FL 19,552,860 South 27 Arkansas Little Rock AR 2,959,373 South 4 Alabama Montgomery AL 4,833,722 South 7 Provide comments in this form for the State, Stack, and PriorityQueue classes: Comments for the class: /** * Detailed description of the class. * * @author * @version */ Public method comments: /** * Description of the purpose of the method, the meaning of the * input parameters (if any) and the meaning of the return values * (if any). * * @param parameter description of the parameter (one for each) * @return description of the return value */ Provide comments in this form for the Project2 class. /** * COP 3538: Project 2 – Stacks and Priority Queues *


* Description of the class using as many lines as needed * with



between paragraphs. Including descriptions of the * input required and output generated. * * @author * @version */ public class Project2 { COP3538 Project 2 – Stacks and Priority Queues Liu University of North Florida 3 Example: COP3538 Project 2 Instructor: Xudong Liu Stacks and Priority Queues Enter the file name: States2.csv There were 22 state records put on the stack. Stack Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Wyoming Cheyenne WY 582,658 West 1 West Virginia Charleston WV 1,805,832 Middle Atlantic 3 Washington D.C. Washington D.C. DC 703,608 Middle Atlantic 0 . . . South Pacific Priority Queue Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Guam Hagatna GU 165,718 South Pacific 0 American Samoa Pago Pago AS 55,679 South Pacific 0 . . . West Priority Queue Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- California Sacramento CA 38,332,521 West 53 Washington Olympia WA 6,971,406 West 10 . . . Middle Atlantic Priority Queue Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- New York Albany NY 19,542,209 Middle Atlantic 27 Pennsylvania Harrisburg PA 12,807,060 Middle Atlantic 18 . . . Stack Contents: State Name Capital City State Abbr State Population Region US House Seats ------------------------------------------------------------------------------------------------------- Washington D.C. Washington D.C. DC 703,608 Middle Atlantic 0 Delaware Dover

Answered 307 days AfterApr 28, 2021

Answer To: Project2 COP3538 Project 2 – Stacks and Priority Queues Liu University of North Florida 1 Due Date:...

Nithin answered on Feb 15 2022
119 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here