Question: please help with this code. please only do the the TODO section as thtas all it needs. I gave a description of the todo in
please help with this code. please only do the the TODO section as thtas all it needs. I gave a description of the todo in this assignment.
Code to write:
StatePair.java
// TODO: Define a constructor, mutators, and accessors
// for StatePair
Constructor needs to take two objects and set the values of the properties. Note: pay attention to what these properties are defined as
Code getKey and setKey which will be used for both zip code and state abbreviation. Remember these are generic types
Code getValue and setValue which will be used for both zip cdoe and state
// TODO: Define printInfo() method
Display the information (Hint: use key and value in your code)
StatePopulations.java
// TODO: Using ZIP code, find state abbreviation
For loop reading through zipCodeState array
If myZipCode value is a key in the array
Assign the corresponding value to myStateAbbrev
// TODO: Using state abbreviation, find state
For loop reading through abbrevState array
If myStateAbbrev is a key in the array
Assign the corresponding value to myState
// TODO: Using state, find population. Print information.
For loop reading through statePopulation array
If myState is a key in the array
Call the printInfo method of statePopulation
NOTE: It is extremely important to understand how StatePair and StatePopluations tie together. In the code you write for StatePopulations you will be using the getKey and getValue methods
Here is the existing code, please plug in the rest.
import java.util.Scanner; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList;
public class StatePopulations {
public static ArrayList
while (inFS.hasNextLine()) { intValue = inFS.nextInt(); stringValue = inFS.next(); pair = new StatePair
while (inFS.hasNextLine()) { stringValue1 = inFS.next(); inFS.nextLine(); stringValue2 = inFS.nextLine(); pair = new StatePair
while (inFS.hasNextLine()) { stringValue = inFS.nextLine(); intValue = inFS.nextInt(); inFS.nextLine(); pair = new StatePair
public class StatePair
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
