Importantly, your program should only read the zip code file once!
After reading and storing all of the zip codes, your program should continuously prompt the user for a zipcode until the user enters '00000' to quit.
Here is a sample session:
zipcode: 19010 Bryn Mawr, PA zipcode: 99400 No such zipcode zipcode: 91729 Rancho Cucamonga, CA zipcode: 00000 Good Bye!In this session everything is from the program other than the 5 digits immediately following "zipcode:"
The data file for this assignmetn can be found in
/home/gtowell/Public206/a2/uszipcodes.csvMore generally, the data files used in this course are found in /home/gtowell/Public206/a.... ('a' as in assignment). Tack on the number appropriate for the assignment. For example, for this assignment (#2), data files are in /home/gtowell/Public206/a2.
The first line is a special line, giving some basic info about the file, in the following comma-separated values:
<num>,zip,city,state,population,males,females,
where the first field in the line is an integer giving you the number of
zip codes stored
in the file. The rest of the line contains column headers for the file. Other than the number of zip codes,
this line can be ignored.
The rest of the lines come in the following format:
<zip>,<town name>,<state code>,<population>,<males>,<females>,where the comma-separated fields have the following meanings:
zip | the 5-digit zipcode |
town name | name of the town with the zipcode |
state code | 2-character encoding of the state name |
population | population in this zipcode, an integer |
males | number of males in this zipcode, an integer |
females | number of females in this zipcode, an integer |
Sample snippet:
42613,zip,city,state,population,males,females, 00501,Holtsville,NY,,,, 00544,Holtsville,NY,,,, 00601,Adjuntas,PR,18570,9078,9492, 00602,Aguada,PR,41520,20396,21124, 00603,Aguadilla,PR,54689,26597,28092,
There are 42,613 entries following the first line. Zipcode 00501 belongs to the town of Holtsville, NY, for which we have no population recorded.
In this assignment, you will ignore the population numbers, and store only the zip code, the town and the state. Note however that there are towns whose names have more than one word, such as “Palm Springs”.
/** * Creates a place with zip, town name and state * @param zip a 5 digit zip code * @param town the town name * @param state the state abbreviation */ public Place(String zip, String town, String state);There are many other ways you might implement the Place constructor. Do it this way in this assignment.
/** * Reads a zip code file, parsing and storing every line * @param fileName the zip code file * @throws FileNotFoundException if the file does not exist */ public void readZipCodes(String fileName) throws FileNotFoundException /** * Find a Place record given a zip code * @param zipCode the zip code to find. * @return the place, or null if the zip code is unknown */ public Place lookupZip(String zipCode)Implement the class Places and the above methods.
Place[] allZips;which will get initialized and filled by readZipCodes. Then the method lookupZip will scan that array to find information.
A smaller file (of the same format), named testZip.csv, is available as well, in case you want to debug on a smaller dataset.
Your submission will be handed in using the submit script.
If you write your program on computers other than those in the lab, be aware that your program will be graded based on how it runs on the department’s Linux server, not how it runs on your computer.The submission should include the following items:
The following steps for submission assume you are using Visual Studio Code, and that you created a folder named Assignment2 in the directory /home/YOU/cs206/