The data files are available via http at
https://cs.brynmawr.edu/cs245/Data/names2000.csv https://cs.brynmawr.edu/cs245/Data/names2001.csv https://cs.brynmawr.edu/cs245/Data/names2002.csv https://cs.brynmawr.edu/cs245/Data/names2003.csv https://cs.brynmawr.edu/cs245/Data/names2004.csv https://cs.brynmawr.edu/cs245/Data/names2005.csv https://cs.brynmawr.edu/cs245/Data/names2006.csv https://cs.brynmawr.edu/cs245/Data/names2007.csv https://cs.brynmawr.edu/cs245/Data/names2008.csv https://cs.brynmawr.edu/cs245/Data/names2009.csvData in the files looks like:
1,Jacob,34471,Emily,25953 2,Michael,32035,Hannah,23080 3,Matthew,28572,Madison,19967 4,Joshua,27538,Ashley,17997 5,Christopher,24931,Sarah,17697 6,Nicholas,24652,Alexis,17629 7,Andrew,23639,Samantha,17266 8,Joseph,22825,Jessica,15709 9,Daniel,22312,Elizabeth,15094 10,Tyler,21503,Taylor,15078Where the columns are:
For example:
UNIX> java -jar hw4.jar Aaron Devon marlen Aaron Boy Aaron 2 19088 0.5524 alphabetic position 1 Devon Boy Devon 2 5695 0.1648 alphabetic position 284 Girl Devon 2 665 0.0234 alphabetic position 317 marlen Girl Marlen 1 212 0.0074 alphabetic position 760The above example is only for the years 2000 and 2001. In this output, you see the name Arron is used as a boy in 2 years, a total of 19088 times for 0.55% of the total boy's names. Alphabetically Aaron is the first boy's name. Aaron is not used as a girl's name. Marlen is not used and a boy's name; it is used in only one year (unspecified) for girls, only 212 times and it is in position 760 alphabetically.
In addition to names your program must work for prefixes of names. Given a prefix, print information as above about each name that matches the prefix. For instance:
java -jar hw4.jar syd syd Girl Sydney 2 19879 0.6981 alphabetic position 982 Girl Sydnee 2 923 0.0324 alphabetic position 981 Girl Sydni 2 867 0.0304 alphabetic position 983 Girl Sydnie 2 657 0.0231 alphabetic position 984Again, the data in this example is for only 2000 and 2001
Your output must include all of this information -- but for all 10 years. Also, I am confident that you can improve on my output presentation.
val readURL = { url:String -> val r = mutableListOfthe call to use this function looks like(); try { val oracle = URL(url); val br = BufferedReader(InputStreamReader(oracle.openStream())); loop@ while (true) { val line = br.readLine(); if (line==null) { break@loop } r.add(line); } } catch (ee: Exception) { println("Problem ${ee}"); } r }
readURL("https://cs.brynmawr.edu/cs245/Data/names2000.csv")
I encourage you to make liberal use of the functional constructs in Kotlin: forEach, map, filter, ... More often than not, clever use of these functions can avoid using loops or recursion. In my implementation I have only 5 recursive functions, and most of those are related to my linked list implementation. (Again, you are not required to write your own linked list; I expect you will be far better served to use List or MutableList)
While I do not require you to define and use classes, I do encourage you to do so. Moreover, if you do something like leaving all of the data in the list of String representation returned by readURL I doubt you will be able to succeed with this task. Worse, even if you do succeed, you will not get a good grade. In my implementation I wrote 5 classes (several of these were for my singly linked list). Suggestion: DO NOT write your own list class. Use the kotlin List. Then use functions defined on list like: map, filter and foreach. The assignment will be far easier doing it that way.)Feel free to have everything in a single file. Kotlin, unlike Java, is content for you to do so.
Suggestion: get a clear picture of all of the work that you think needs to be done. Then, build everything bottom up. That is, take your idea and ask the question, what do I need to do? Each time you get know what you need to do, ask, what do I need for that. Keep doing this until you get to the point where the answer involves 10 or fewer lines of code and no variables. Then write that code and test that code. Phrased alternately, write little functions that can be composed into bigger functions. Write little tests of your little functions. Write, test, write, test, put together, test, ... By so doing, you always have a program that does something. Even better, when you get to the end, if you are doing this correctly, there should be little to do. Everything should work because you have tested everything along the way.Soapbox: One advantage of taking this approach to programming is that when you are learning a language, you are always asking a question that is reasonably easy to get an answer. So, for instance, when I wrote an implementation of this assignment, I constantly faced the question "how do I do that". But my questions were always small enough that it was easy to get an answer for my reference books or the web.
For example, in my development of this program I first wrote something to hold information about a single name. Then I tested that. Then I put 2 of those objects into a list, and tested the list. Then I wrote something to find a single item within the list, ... I expect your process will be quite different.
Your submission will be handed in using the submit script.
If you write your program on computers other than those in the lab, be aware that your program will be graded based on how it runs on the department’s Linux server, not how it runs on your computer. The most likely problem is not submitting everything or hard coding file locations that are not correct on the Linux servers.The submission should include the following items:
Again: Once you have everything you want to submit in the a4 directory within /home/YOU/cs245/