In this project, you will practice file input, class design and arrays. All programming assignments will go through auto-testing for correctness so it is important that you pay attention to naming conventions. In other words, name your classes, methods and directories EXACTLY as given here, including cases.
All programming assignments in this class will follow the convention of naming the class that contains the main method, Main. Thus the corresponding file should be named Main.java. Other class may be named as you see fit.
In addition, please read the program design principles (http://cs.brynmawr.edu/cs206/design.pdf) and code formatting standards (http://cs.brynmawr.edu/cs206/style.html) carefully. You are expected to adhere to all stated standards.
All data files are used in this course are found in /home/gtowell/Public206/data. Look under the appropriate
subdirectory. For example, for this assignment (#1), look in /home/gtowell/Public206/data/a1.
The file uszipcodes.csv contains all zipcodes used in the United States. Your program should read the data from exactly this location. (More precisely, the version of the program that you submit MUST read the file from exactly this location.)
Here are the details of the data file’s format:The first line is a special line, giving some basic info about the file, in the following comma-separated values:
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:
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:
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”.
Implement the class LookupZip and the above methods.
Place[] places; int knownPlaces; ...... places = new Place[knownPlaces];You program should only read the zip code file once!
Here’s a sample session:
A reminder that your program will undergo auto-testing, thus it is important that you stick to the output format EXACTLY. That means exactly the same amount of white spaces and exactly the same punctuation.
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 Eclipse, and that you created a project named Assignment2 in the directory /home/YOU/cs206/