CS 307Assignment, Baby Names

Programming Assignment 3: You must complete this assignment on your own. You may not discuss their work with anyone except the instructor and other members of the instructional staff (TA, section leader, or lab proctor). You may not acquire, from any source (e.g., another student or an internet site), a partial or complete solution to a problem or project that has been assigned. You may not show another student your solution to an assignment. You may not have another person (current student, former student, tutor, friend, anyone) “walk you through” how to solve an assignment. Review the class policy on collaboration from the syllabus.

The purposes of this assignment are:

  1. to work with ArrayLists
  2. to implement a program that uses multiple classes
  3. to practice processing input
  4. to practice implementing individual classes based on a given specification

Files:

  File Responsibility
Source Code NameSurfer.java Provided by me and you
Source Code NameRecord.java Provided by you.
Source Code Names.java Provided by you.
data file

names.txt

Provided by me.
sample run log nameSurferLog.txt Provided by me.
Submission A4.jar Provided by you

Description: This assignment is based on an assignment created by Nick Parlante and Stuart Reges' version of the assignment..

Complete a program that allows a user to query a data base of the 1000 most popular baby names in the United States per decade under the constraints of the General Assignment Requirements and as described below. (As always, you may add helper methods.) One additional constraint: You must use the ArrayList class in the solution as discussed below. You are encouraged to use methods from the ArrayList class and String class to make the program easier to write. The ArrayList class has lots of methods that can make your job easier and one of the goals of this assignment is to learn those methods. Don't try to do everything by hand with the get method and loops. Make use of those methods in ArrayList.

Your program will be processing a file with data obtained from the Social Security Administration.  They provide a web site showing the distribution of names chosen for children over the last 100 years in the US (www.ssa.gov/OACT/babynames/).

The data represent the 1000 most popular boy and girl names for kids born in the US going back to 1900. 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 lines are in alphabetical order.

...
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. The database is for children born in the US, so ethnic trends show up when immigrants have kids.

You will be provided with one class, NameSurfer.java. This is the main driver class. When this class's main method is called it opens a window to pick the file with the names in it. The file is called names.txt. After creating the database of names encapsulated in a class called Names.java the program displays a menu and allows the user to make various queries of the database. The provided version of names shows five of the options and you will add two more.


Suggested steps for implementing the program.

1. Implement a class called NameRecord. This stores the data for an individual name, including the name itself (a String) and the rank of the name for each of the 11 decades. The ranks for each decade must be stored in an ArrayList of Integers. The class should have the following properties (you may add more methods if you wish):

After completing all these methods you should thoroughly test the NameRecord class using individual lines from the names.txt file or with your own data. Include your testing code in your NameSurfer class even though it will not be called when the program is run. Part of the assignment grade will be based on the tests you write for the NameRecord class.

2. Implement the Names class. This class stores all of the NameRecord objects in an ArrayList. This class must have the following methods.

3. Complete the methods in the NameSurfer class and make changes to the menu to include the three options that are not yet present.

The menu choices are:

1 to search for names.
2 to display data for one name.
3 to display all names that appear in only one decade.
4 to display all names that appear in all decades.
5 to display all names that are more popular in every decade.
6 to display all names that are less popular in every decade.
7 to perform the method of your own design from your Names class
8 to quit

4. Neat searches. This is an interesting application because when your program is finished you can investigate various trends in naming children as well as others. In a comment at the top of the file discuss one interesting trend you found.

Nick got the idea for this assignment from an article by Peggy Orenstein of the New York Times, Where have all the Lisas Gone?


Submission: Fill in the header for ArrayProblems.java. Replace <NAME> with your name. Note, you are stating, on your honor, that you did the assignment on your own, as required. If you do the extra work suggested below include the DrawPanel.java class in your jar as well.

When finished turn in a jar file named A4.jar that contains the NameSurfer.java, Names.java, and NameRecord.java files using the turnin program. jar is a program included in the standard edition of Java loaded on the computers in the Microlab and that you have on your computer if you downloaded Java. See Sun's page for using jar, my tips for using jar, and / or the guide to creating jars in Eclipse.

Ensure you jar the .java files not the .class files.

Checklist: Did you remember to:


Extra: (No extra points juts good karma.)

If you are looking for something fun and extra to do, add a feature to name surfer so that when the user searches for information on a single name (option 2) a DrawingPanel is created with a simple line graph showing the ranking of the name over time. It is often easier to interpret visual information. Here is an example:

Use the DrawingPanel class. (This is a non stadard Java class with various methods for drawing lines.) Strings can be added to the window by getting the Graphics object and using the drawString method. If you use this class be sure to include DrawingPanel in your jar file.

  Back to the CS 307 homepage.