Hi, I need help with this project: Using JAVA language Requirements: 1. Create a
ID: 2247577 • Letter: H
Question
Hi,
I need help with this project:
Using JAVA language
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:
Please provide comments to explain
Thank you
Explanation / Answer
class state
{
private string statename;
private string capitalcity;
private string stateabbriviation;
private int statepopulation;
private string region;
private int ushouseseats;
public state(string a,sting b,string c,int d,string e,int f)
{
statename=a;
capital city=b;
stateabbreviation=c;
statepopulation=d;
region=e;
ushouseseats=f;
}
public string getstatename()
{
return statename;
}
public string getcapitalcity()
{
return capitalcity;
}
public string getstateabbreviation()
{
return stateabbreviation;
}
public int getstatepopulation()
{
return statepopulation;
}
public string getregion()
{
return region;
}
public int getushouseseats()
{
return ushouseseats;
}
}
class project1
{
public static void main(string []args)
{
state g=new state("florida","tallahassee","FL",19552860,"south",27);
systam.out.println(g.getstatename());
system.out.println(g.getcapitalcity());
system.out.println(g.getstateabbreviation());
system.out.println(g.getstatepopulation());
system.out.println(g.getregion());
system.out.println(g.getushouseseats());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.