In this assignment, we'll be exploring linked lists and more complex custom-designed classes.
rank,male-name,male-number,female-name,female-numberwhere the comma-separated fields have the following meanings:
rank | the ranking of the names in this file |
---|---|
male-name | a male name of this rank |
male-number | number of males with this name |
female-name | a female name of this rank |
female-number | number of females with this name |
1,Jacob,30568,Emily,24463 2,Michael,28246,Madison,21773 3,Joshua,25986,Hannah,18819 4,Matthew,25151,Emma,16538 5,Ethan,22108,Alexis,15636 6,Andrew,22017,Ashley,15342 7,Joseph,21891,Abigail,15297 8,Christopher,21681,Sarah,14758 9,Nicholas,21389,Samantha,14662 10,Daniel,21315,Olivia,14630 ... 996,Ean,157,Johana,221 997,Jovanni,157,Juana,221 998,Alton,156,Juanita,221 999,Gerard,156,Katerina,221 1000,Keandre,156,Amiya,220As you can see from the above, in 2002, there were 30,568 male babies named Jacob and 24,463 female babies named Emily, making them the most popular names used in that year. Similarly, going down the list, we see that there were 220 newborn females named Amiya, making it the 1000th most popular female baby name.
The entire data set contains a file for each year from 1990 to 2017, named names1990.csv, ..., names2017.csv. These files are in /home/gtowell/Public206/data/a4. You should use the files directly from this location. Do not make a local copy. Grading will not use local copies. (As always, for development you may do what is convenient, but this rule applies to the version you hand in.)
1990 Mary: 35, 8666, 0.005432, 734 ... 1999 Mary: 38, 8760, 0.005596, 727 ... 2017 Mary: 126, 2381, 0.001877, 720You should design a Name class that stores all the relevant stats for a particular name. The two linked lists you are building should be from scratch; you are not allowed to use Java's built-in LinkedList class. You may use code from lectures notes or the book. Also, although generic linked lists have many advantages, your code will be simplified if you use non-generic linked lists that are locked to the Name class.
Computing the yearly percentages requires additional data not stored in the linked lists. Consider what you need and decide where and how to store the information carefully.
You may find it convenient to have two linked lists for every year for which you have data. Taking this approach, it might be convenient to store the linked lists in an two array lists, one for boys and one for girls.) As an alternative, you could just have one liked list for boys and one for girls. This approach make some aspects or the task easier, but some are much harder.
java -cp bin Main -f Dianna /home/gtowell/Public206/data/a4/names1990.csv /home/gtowell/Public206/data/a4/names2000.csvwill print out the ranks (alphabetic and numeric), number and percentages (as explained above) of the female name Dianna used in 1990 and 2000.
Other possible command line input include (but are not limited to):
java -cp bin Main -f Mary -f Amie -m DaviD /home/gtowell/Public206/data/a4/names1991.csv java -cp bin Main -f Devon -m Devon /home/gtowell/Public206/data/a4/names1993.csv /home/gtowell/Public206/data/a4/names1994.csv /home/gtowell/Public206/data/a4/names1995.csv /home/gtowell/Public206/data/a4/names1991.csvYou many assume that the list of filenames is always last. That is once you see a file name you will not see a person name or a -f/-m. All subsequent arguments should be assumed to be data file names. Make sure you error-check your arguments thoroughly, i.e. illegal/badly-formated/missing options. Your program should behave rationally no matter how unreasonable the input.
If you are using eclipse for development, and your is named Assignment4, then you should be able to run your program from the command line by doing the following. First open a terminal by selecting "Applications / System Tools / MATE Terminal" from the menus in the upper left. Then
cd /home/YOU/cs206/Assignment4After this you should be able to use commands like the one above.
public static void main(String[] args) { String[] myArgs = {"-f", "Dianna", "/home/gtowell/Public206/data/a4/names1990.csv"}; args = myArgs; ... }
1990 Mary: 35, 8666, 0.005432, 734 2017 Mary: 126, 2381, 0.001877, 720 TOTAL: Mary: 110, 12477, 0.002231, 700(I made up the total numbers). What additional data would you need to keep. In particular, suggest what you would need to do to get the total numeric rank and total alphabetic rank. (Simple average is not correct.) Do not implement this, just suggest what you would need to do to extend you program in this manner.
The following steps for submission assume you are using Eclipse, and that you created a project named Assignment4 in the directory /home/YOU/cs206/