Answered Essay: Please use comments for each class, methods and constructor

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 <your last name>_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 <date you last changed the class>

*/

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

* <p>

* Description of the class using as many lines as needed

* with <p> 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!

Expert Answer

 

1)

/**
* Captures information about US State
* Fields include statename,capital,abbreviation,population,region and house seats.
*
* @author <your name>
* @version 09-10-2017
*/

public class State{
String statename;
String capital;
String abbreviation;
int population;
String region;
int houseseats;

public State(String statename,String capital,String abbreviation,int population,String region,int houseseats){
this.statename=statename;
this.capital=capital;
this.abbreviation=abbreviation;
this.population=population;
this.region=region;
this.houseseats=houseseats;
}
/**
* Getter for statename
*
* @return statename
*/
public String getStateName(){
return statename;
}
/**
* Setter for statename
*
* @param statename
*/
public void setStateName(String statename){
this.statename=statename;
}
/**
* Getter for capital
*
* @return capital
*/

public String getCapital(){
return capital;
}
/**
* Setter for capital
*
* @param capital
*/

public void setCapital(String capital){
this.capital=capital;
}
/**
* Getter for abbreviation
*
* @return abbreviation
*/

public String getAbbreviation(){
return abbreviation;
}
/**
* Setter for abbreviation
*
* @param abbreviation
*/

public void setAbbreviation(String abbreviation){
this.abbreviation=abbreviation;
}
/**
* Getter for population
*
* @return population
*/

public int getPopulation(){
return population;
}
/**
* Setter for population
*
* @param population
*/

public void setPopulation(int population){
this.population=population;
}
/**
* Getter for region
*
* @return region
*/

public String geRegion(){
return region;
}
/**
* Setter for region
*
* @param region
*/

public void setRegion(String region){
this.region=region;
}
/**
* Getter for house seats
*
* @return houseseats
*/
public int getHouseSeats(){
return houseseats;
}
/**
* Setter for houseseats
*
* @param houseseats
*/
public void setHouseSeats(int houseseats){
this.houseseats=houseseats;
}
/**
* Given a state object, the method checks if it is the same as current
* state by comparing the names
*
* @param s State object passed as input
* @return true if states are same, false otherwise
*/
public boolean compare(State s){
if(statename.equals(s.statename))return true;
else return false;
}
/**
* Generates a String representation of the state data
*
*/
public void print(){
System.out.println(“State Name:” + statename);
System.out.println(“Capital: ” + capital);
System.out.println(“Abbreviation: ” + abbreviation);
System.out.println(“Population: ” + population);
System.out.println(“Region: ” + region);
System.out.println(“House Seats: ” + houseseats);
}

 

public static void main(String []args){
System.out.println(“Hello World”);
}
}

2)

/**
* COP 3538: Project 1 – Array Searches and Sorts
* <p>
* This class reads the input csv file and populates an array of states.
* Then it carries out operations on the state array as per the input
* received from the user
*
* Following ooptions are provided:
* 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 statename, sequential search if not)
* 6) Quit
*
* @author <your name>
* @version 10-09-2017
*/
public class Project1{
State[] s = new State[50];
int numstates; // Actual Number of states read from csv
/**
* Method to read the state data from specified csv file
*
*/
public void readStates(){
//Reads the state data from the csv file and populates the array
}
/**
* Method to print state report from the data populated in the state array.
*
*/
public void printStateReport(){
for(int i=0;i<numstates;i++){
s[i].print();
}
}
/**
* Method to sort the state array by state names in alphabetic order
*
*/

public void sortByStateName(){
//Sorts the array s in alphabetic order by statename
}
/**
* Method to sort the state array by state’s population
*
*/

public void sortByPopulation(){
//Sorts the array s by state’s population
}
/**
* Method to sort the state array by region
*
*/
public void sortByRegion(){
//Sorts the array s in alphabetic order by region
}
/**
* Method to find a particular state and print it details
*
* @param st State which needs to be found in the array
*/
public void findState(State st){
for(int i=0;i<numstates;i++){
if(s[i].getStateName().equals(st.getStateName()))s[i].print();
}
}

/**
* Main method – creates an instance of the Project1 object and
* populates the state array.
* It then presents options for operations to user and carries out
* the required task based on input received.
*/

public static void main(String []args){
Project1 p = new Project1();
p.readStates();
while(true){
try{
System.out.println(“Enter your choice”);
System.out.println(“1. Print a state report”);
System.out.println(“2. Sort by State name”);
System.out.println(“3. Sort by Population”);
System.out.println(“4. Sort by Region”);
System.out.println(“5. Find and print a given state”);
System.out.println(“6. Quit”);
Scanner s = new Scanner(System.in);
int option=s.nextInt();
if(option==1){
p.printStateReport();
}
if(option==2){
p.sortByStateName();
}
if(option==3){
p.sortByPopulation();
}
if(option==4){
p.sortByRegion();
}
if(option==5){
Scanner sc = new Scanner(System.in);
String state=sc.nextLine();

p.findState(new State(state,””,””,0,””,0));
}
if(option==6){
break;
}
else{
continue;
}
}catch(Exception e){
continue;
}
}
}
}

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?