UNIX> java Main -f Mary -f Nancy -m Devon -f Devon -m Mark -f Marlen -f Zoe /home/gtowell/Public206/a4/names2000.csv /home/gtowell/Public206/a4/names2001.csv Mary Girls Alpha Rank: 293 of 1057 [2000, 2001] Percentage: 0.41863382305636054 Nancy Girls Alpha Rank: 239 of 1057 Years: [2000, 2001] Percentage: 0.09811785098728892 Devon Boys Alpha Rank: 759 of 1042 Years: [2000, 2001] Percentage: 0.16482288847264318 Devon Girls Alpha Rank: 741 of 1057 Years: [2000, 2001] Percentage: 0.023353031820525103 Mark Boys Alpha Rank: 336 of 1042 Years: [2000, 2001] Percentage: 0.2887222362428601 Marlen Girls Alpha Rank: 298 of 1057 [2000] Percentage: 0.007444876309701236 Zoe Girls Alpha Rank: 3 of 1057 [2000, 2001] Percentage: 0.2960040679927911The above formatting is meant as an example; not a requirement. Formating of the output is up to you. That said, the output must contain the required information. Note that the girls name Marlen only appears in the list for the year 2000.
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,220From the above, in 2002, the most popular baby names were Jacob with 30,568 male babies, and Emily with 24,463 female babies. Similarly, going down the list, 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.)
Design a class that stores all the relevant stats for a particular name.
Computing the overall percentages requires additional data not stored in the linked lists. Consider what you need and decide where and how to store the information carefully.
When adding a name to a linked list, you must be able to handle that the name is already in the list. In such cases, rather than inserting a new item into the linked list, you should add information (the count and the year) to the existing item.
Suggested steps:
public static void main(String[] args) { String[] myArgs = {"-f", "Dianna", "/home/gtowell/Public206/data/a4/names1990.csv"}; if (args.length == 0) args = myArgs; ... }Doing something like this will make development far quicker. To test with actual command line input you need only provide input on the command line.
java 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 Main -f Mary -f Amie -m DaviD /home/gtowell/Public206/data/a4/names1991.csv java 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.csvFilenames are always last; nothing follows a filename other than another filename. That is once you see a file name you will not see a person name or a -f/-m. 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 Visual Studio Code for development, and your folder is named Assignment4, then you should be able to run your program from the command line as in Lab 4. Specifically, first open a terminal by selecting "Applications / System Tools / MATE Terminal" from the menus in the upper left. Then
cd /home/YOU/206/Assignment4/ javac Main.javaAfter this you should be able to use commands like those above.
The following steps for submission assume that you created a folder named Assignment4 in the directory /home/YOU/cs206/ and that all of your code, along with the README file, is inn this directory.