Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this project: Please use comments for each class, methods and constructor and Thanks. COP3538 Project 1 Array Searches and Sorts Using

I need help with this project:

Please use comments for each class, methods and constructor

and Thanks.

COP3538 Project 1 Array Searches and Sorts

Using JAVA language

Due Date: Friday, 9/15/2017 11:59 PM

Submit the zipped Eclipse program including at least Project1.java, State.java and States1.csv.

The zip file should be named _Project1.zip (for example, Liu_Project1.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. Create a class named State that will store information about a US state and provide methods

to get, and set the data, and compare the states by several fields.

a. Fields: State Name, Capital City, State Abbreviation, State Population, Region, US

House Seats

b. Constructor

c. Get and set methods for each field

d. Compare method to compare based on State Name (expects a State object as a

parameter)

e. Method to print a state

2. Create a class named Project1 that will:

a. Read the file (csv) of states and create an array of state objects containing that data.

b. Offer the user the following options:

1) Print a state report

2) Sort by state name (using Bubble sort)

3) Sort by population (using Selection sort)

4) Sort by Region (using Insertion sort)

5) Find and print a given state (using binary search if the data is sorted by state

name, sequential search if not)

6) Quit

c. Implement the given option, then prompt again. (deal with invalid choice)

Project1 should have main and methods for each options 1-5.

d. The State report in option 1 should be in this form:

State Name Capital City State Abbr State Population Region US House Seats

------------------------------------------------------------------------------------------

Florida Tallahassee FL 19,552,860 South 27

Pennsylvania Harrisburg PA 12,773,801 Middle Atlantic 18

Massachusetts Boston MA 6,692,824 New England 9

e. The State report in option 5 should be in this form:

State Name: Florida

Capital City: Tallahassee

State Abbr: FL

State Population: 19,552,860

Region: South

US House Seats: 27

Provide comments in this form for the State class:

COP3538 Project 1 Array Searches and Sorts

Liu University of North Florida 2

Comments for the class:

/**

* Detailed description of the class.

*

* @author <your name>

* @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 Project1 class.

Comments for the class:

/**

* COP 3538: Project 1 Array Searches and Sorts

*

* Description of the class using as many lines as needed

* with

between paragraphs. Including descriptions of the

* input required and output generated.

*

* @author <your name>

* @version <the date you last modified the program>

*/

public class Project1

{

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

*/

COP3538 Project 1 Array Searches and Sorts

Liu University of North Florida 3

Output Example:

COP3538 Project 1

Instructor: Xudong Liu

Array Searches and Sorts

Enter the file name: States1.csv

There were 50 state records read.

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 1

State Name Capital City State Abbr State Population Region US House Seats

------------------------------------------------------------------------------------------

Mississippi Jackson MS 2,991,207 South 4

New Hampshire Concord NH 1,323,459 New England 2

Pennsylvania Harrisburg PA 12,773,801 Middle Atlantic 18

. . .

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 3

States sorted by Population.

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 1

State Name Capital City State Abbr State Population Region US House Seats

------------------------------------------------------------------------------------------

Wyoming Cheyenne WY 582,658 West 1

Vermont Montpelier VT 626,630 New England 1

North Dakota Bismarck ND 723,393 Midwest 1

. . .

COP3538 Project 1 Array Searches and Sorts

Liu University of North Florida 4

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 5

Enter the state name: Florida

Sequential search

State Name: Florida

Capital City: Tallahassee

State Abbr: FL

State Population: 19,552,860

Region: South

US House Seats: 27

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 5

Enter the state name: Canada

Sequential search

Error: State Canada not found

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 2

States sorted by State name.

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 1

State Name Capital City State Abbr State Population Region US House Seats

------------------------------------------------------------------------------------------

COP3538 Project 1 Array Searches and Sorts

Liu University of North Florida 5

Alabama Montgomery AL 4,833,722 South 7

Alaska Juno AK 735,132 West 1

Arizona Phoenix AZ 6,626,624 Southwest 9

. . .

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 5

Enter the state name: Kentucky

Binary search

State Name: Kentucky

Capital City: Frankfort

State Abbr: KY

State Population: 4,395,295

Region: South

US House Seats: 6

1. Print a state report

2. Sort by State name

3. Sort by Population

4. Sort by Region

5. Find and print a given state

6. Quit

Enter your choice: 23

Invalid choice enter 1-6: 0

Invalid choice enter 1-6: A

Invalid choice enter 1-6: 6

Have a good day!

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

More Books

Students also viewed these Databases questions

Question

1. How might volunteering help the employer and the employee?

Answered: 1 week ago