Question: Phase 2 (60 pts) Step 4: Create two comparator classes called SortByPopulationDensity and SortByMedianAge (10 pts) - initial code given ' The class SortByPopulationDensity contains

 Phase 2 (60 pts) Step 4: Create two comparator classes called

Phase 2 (60 pts) Step 4: Create two comparator classes called SortByPopulationDensity and SortByMedianAge (10 pts) - initial code given ' The class SortByPopulationDensity contains one single method public int compare (State a, State b). This method will return: 0 A negative integer value if the population density of state a is larger than the population density of state b 0 0 if the two population densities are the same 0 A positive integer value if the population density of state b is larger than the population density of state a. ' The class SortByMedianAge contains one single method public int compare (State a, State b). This method will return: 0 A negative integer value if the median age of state a is smaller than the median age of state b 0 0 if the two median ages are the same 0 A positive integer value if the median age of state a is larger than the median age of state a. Step 5: Create a class called StateCollection (40 pts) - initial code given Create a class that maintains the collection of the countries of the world - an ArrayLiSt of elements of the class State . A skeleton for this class is provided. Instance variables 1 class fields: Declare an instance variable that holds an ArrayList of elements of the State class. The name of this variable should be st ateList. Constructor: Instantiate the ArrayLiSt of States. Mutator Methods ' public void loadFromFile( ) - Most of the code for this method is provided. It opens the file States . csv and reads the data into the ArrayList. Look for TO DO instructions to complete the code (only two instructions need to be added) Note: The data file contains information of 51 states (includes Washington DC. as a state). A sample line is shown below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!