CompSci 6 Spring 2010: Assignment 5

Due: Tuesday, Mar 2 - 11:59pm

10 points

This assignment focuses on files and arrays.

Snarf the assign5_cps006 project to get started.

We will start with the code:

Problem

Against all bureaucratic stereotypes, the Social Security Administration, provides a neat web site showing the distribution of names chosen for kids over the last 100 years in the US. Every 10 years, the data gives the 1000 most popular boy and girl names for kids born in the US. The data can be boiled down to a single text file as shown below. On each line we have the name, followed by the rank of that name in 1900, 1910, 1920, ... 2000 (11 numbers). A rank of 1 was the most popular name that year, while a rank of 997 was not very popular. A 0 means the name did not appear in the top 1000 that year at all. The elements on each line are separated from each other by a single space.

...
Sam 58 69 99 131 168 236 278 380 467 408 466
Samantha 0 0 0 0 0 0 272 107 26 5 7
Samara 0 0 0 0 0 0 0 0 0 0 886
Samir 0 0 0 0 0 0 0 0 920 0 798
Sammie 537 545 351 325 333 396 565 772 930 0 0
Sammy 0 887 544 299 202 262 321 395 575 639 755
Samson 0 0 0 0 0 0 0 0 0 0 915
Samuel 31 41 46 60 61 71 83 61 52 35 28
Sandi 0 0 0 0 704 864 621 695 0 0 0
Sandra 0 942 606 50 6 12 11 39 94 168 257
... 

We see that "Sam" was #58 in 1900 and is slowly moving down. "Samantha" popped on the scene in 1960 and is moving up strong to #7. "Samir" barely appears in 1980, but by 2000 is up to #798. Ultimately, we want to graph each name's popularity as a bar graph. Here is a sample of graphing Susan showing it was very popular in the 40s through 70s and since has been declining.

To make the program work, complete the following methods:

  1. Complete the constructor for the class NameRecord.
  2. A formatted string containing one line from the data file is passed in (a name (one word) and ranks from many decades) and needs to be stored. The ranks should be stored in an ArrayList.

  3. Complete the accessor methods, getName and getRank, for the NameRecord class. Note that getRank is given a decade number (0, 1, 2, ...) and returns the rank of the name that decade.
  4. Complete the constructor for the class NameDatabase. Note that the name of the file is passed in as a parameter. The name of the file is set in Main.java, which you should not modify.
  5. Complete the match method for the NameRecord class. You should match a name even if the case is not the same. That is Susan and susan should match.
  6. Complete the match method for the NameDatabase class. You should call the method for the NameRecord class in your code.

Submit

Create a README file with both of your names in it if you work with a partner.

Electronically submit through Eclipse your Java code and README file to the assign5 folder.