CS 206 - Introduction to Data Structures

Homework 3

ArrayList - Zipcode lookup

Due Thursday, Feb 13 prior to 11:59PM

Read the program design principles and code formatting standards carefully. You are expected to adhere to all stated standards.

Overview

This project uses ArrayList (use java.util.ArrayList) and object-oriented design with inheritance. You will build on top of your Assignment 2. There is now a second input file ziplocs.csv which gives information about zipcodes and their associated latitudes and longitudes (as decimal numbers). Your task this week is to weave the two data files together and organize the data into classes stored in an ArrayList that allows us to perform similar lookups as those in Assignment 2.

Input File Format

The file ziplocs.csv (/home/gtowell/Public206/a3/ziplocs.csv) contains a header line at the top with column names, but it does not list the number of entries in the file. Thereafter, the lines contain 12 comma-separated fields that look like this:
"07677","STANDARD","WOODCLIFF LAKE","NJ","PRIMARY",41.02,-74.05,"NA-  
US-NJ-WOODCLIFF LAKE","false",2945,5471,325436960

We will only use three of these fields, the zipcode (#1), the latitude (#6) and the longitude (#7). In the sample line, that is 07677 (in quotes), 41.02 and -74.05.

As in the last assignment, some lines are missing some information, but all lines have the correct number of commas (11).

The following little java program shows how to remove quotation marks from a string

    public class A {
    public static void main(String[] args) {
	    String s = "\"This is a test\"";
            System.out.println(s);
            String sr = s.replace("\"", "");
            System.out.println(sr);
    }}
    

Design

In your last assignment, your program only read the zipcode, town and state fields from uszipcodes.csv, but ignored the population information. Your program will now read the total population field as well, if it is not missing.

Collating the data between uszipcodes.csv and ziplocs.csv yeilds three categories: zipcodes with a population and location, zipcodes with a location only, and zip codes without either. (Interestingly, the dataset does not contain any zipcodes with a population but no location.) Call the first a PopulatedPlace, the second a LocatedPlace, and the third just a Place. These types naturally form an inheritance hierarchy, where PopulatedPlace is a subclass of LocatedPlace (every PopulatedPlace is also a LocatedPlace) and LocatedPlace is a subclass of Place (every LocatedPlace is also a Place).

Specific Tasks

Electronic Submissions

Your program will be graded based on how it runs on the department’s Linux server, not how it runs on your computer.

1. README:

The usual plain text file README
2. Source files:
The set of source files is likely to include: Main.java, Place.java, LocatedPlace.java, PopulatedPlace.java, LookUpZip.java

3. Data files used:
uszipcodes.csv, ziplocs.csv
DO NOT INCLUDE:
Data files that are read from the class site.

The following steps for submission assume you are using Eclipse, and that you created a project named Assignment3 in the directory /home/YOU/cs206/

  1. Put the README file into the project directory (/home/YOU/cs206/Assignment3)
  2. Go to the directory /home/YOU/cs206/Assignment3/
  3. Enter submit -c 206 -p 3 -d Assignment3
For more on using the submit script click here