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 for the past 11 decades under the constraints described below. As always, you may add helper methods and should do so to provide structure to the program and reduce redundancy. One additional constraint: You must use ArrayList class in the solution. You are encouraged to use methods in the String and ArrayList 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. Do not try to do everything by hand with the get method and loops. Make use of the 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 children 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
...
Note, a 0 in the data file means the name was not ranked in the top 1000 for the corresponding decade. It has some unknown rank greater than 1000. When you store a 0 from the data file in your NameRecord objects you may use something other than 0 if you think it will make your algorithms easier to implement. (Recall altering the way data is stored to fit our needs is part of the magic of programming.)
We see that Sam was #58 in 1900 and is slowly moving down. Samantha 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 are provided with one class, NameSurfer.java . This is the main driver class. When the main() method of this class 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.
0. These suggested steps describe implementing the requirements. You may add more methods if you want. You may store data in a different form than the input file. For example, the files uses a 0 to indicate the name had a rank greater than 1000 for a given decade. You can store a value other than 0 if you want. (The value for not ranked in a given decade is on the other side of the wall of abstraction.)
1. Implement and test the class called NameRecord. Objects of this type store 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 must have the following properties:
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 and test the Names class. This class stores all of the NameRecord objects in an ArrayList. (private ArrayList<NameRecord> names) 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
For expected program behavior review
the sample run log. Your output shall match that of the sample
run log for the various operations, except that you will not trim the output
for operations that results in a large number of names and your output will
include the description of the search you developed. (Show them all!)
4. Neat searches. This is an interesting application because when your program is finished you can investigate various trends in naming children. In a comment at the top of the file discuss one interesting trend you found. Here are some examples. (You may not use these as your interesting trend.)
The purposes of this assignment are
You must complete this assignment on your own. You may not acquire from another person or the internet a partial or complete solution to this assignment. You may not show another student your solution to an assignment. You may not have another person (other than the instructor, TAs, or proctors) walk you through the solution. You may only discuss general ideas and approaches with other students but you may not develop code together.
You will submit the file NameSurfer.java. It will have the classes - NameSurfer, NameRecord, and Names. We will be looking at good documentation, design, and adherence to the coding convention mentioned below. Here is the initial structure of your program. Your code must have the following header:
/* File: NameSurfer.java Description: Student Name: Student UT EID: Course Name: CS 312 Unique Number: Date Created: Date Last Modified: */
You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code. For example:
Do this:
if ( x > 5 )
{
a = b + c;
}
Not this:
if ( x > 5 ) {
a = b + c;
}
Use the turnin program to submit your NameSurfer.java file. The TAs should receive your work by 11 PM on Saturday 19 November 2011. There will be substantial penalties if you do not adhere to the guidelines. The TA in charge of this assignment will be Sarah Abraham (theshark@cs.utexas.edu).
This assignment is based on an assignment created by Nick Parlante and Stuart Reges and modified by Mike Scott. Nick Parlante got the idea for this assignment from an article by Peggy Orenstein in the New York Times, Where have all the Lisas Gone?