Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8 I need answer for this in java please 8.6 LAB: Zip code and population (generic types) Define a class StatePair with two generic types

8

I need answer for this in java please

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

8.6 LAB: Zip code and population (generic types) Define a class StatePair with two generic types (Typel and Type2), a constructor, mutators, accessors, and a printinfo0 method. Three ArrayLists have been pre-iilled with StatePair data in main): - Arraylist> zipCodestate: Contains ZIP code/state abbreviation pairs - ArrayList abbrevState: Contains state abbreviation/state name pairs - Arraylists statePopulation: Contains state name/population pairs Complete main0 to use an input ZIP code to retrieve the correct state abbreviation from the ArrayList zipCodeState. Then use the state abbreviation to retrieve the state name from the ArrayList abbrevState. Lastly, use the state name to retrieve the correct state name/population pair from the ArrayList statePopulation and output the pair. Ex: If the input is: 21044 the output is: Maryland: 6079602 Current file: StatePopulations.java - Load default template... When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading. When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading. When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading. Current file: StatePopulations.java - Load default template... 47 intValue = inFS.nextInt(); 48 inFS. nextline(); 49 pair = new StatePair (stringValue, intValue); 50 statePairs.add(pair); 51} 52 return statePairs; 53} 54 55 56 public static void main(String args) throws IOException \{ 57 Scanner scnr = new Scanner(System. in); 58 FileInputStream fileByteStream = null; // File input stream 59 Scanner inFS = null; // Scanner object 60 int myZipCode; 61 int i; 62 When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading. Current file: StatePopulations.java Load default template... 63// ZIP code - state abbrev. pairs 64 Arraylist zipCodeState = new ArrayList > (); 65 66 // state abbrev. - state name pairs 67 ArrayList> abbrevState = new ArrayList (); 68 // state name - population pairs 70 ArrayList statePopulation = new ArrayList StatePair > (); 72 // Fill the three Arraylists 73 74 // Try to open zip_code_state. txt file 75 fileByteStream = new FileInputStream("zip_code_state.txt"); 76 inFS = new Scanner(fileByteStream) 77 zipCodeState = fillArray1(zipCodeState, inFS); 78 filebyteStream. close(); // close() may throw IOException if fails When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading. Current file: StatePopulations.java - Load default template... When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading. 94 95 for (i=0;i

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_2

Step: 3

blur-text-image_3

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago