| CIS 210 Home Page | Last updated 2007/10/11 20:57:55 |
Much of the code for LetterFrequency has already been provided to you in LetterFrequency.java. To complete it you will need to fill in a few pieces of code, primarily loops that run through the arrays. To test your code, you will also need to download FrequencyGraph.java and compile it, but you will not need to make any changes to this driver. (However, if you are interested in seeing how to read from an input file you can find that in the driver code.)
Notice that the frequency counts are not printed for characters that appear in less than one percent of the text.$ java FrequencyGraph Somefile.txt Most frequent character 'e' occurs 113 times [a] (0080=08%) ******** [b] (0031=03%) *** [c] (0029=02%) ** [d] (0018=01%) * [e] (0113=11%) *********** [f] (0011=01%) * [g] (0028=02%) ** [h] (0037=03%) *** [i] (0067=06%) ****** [j] (0010=01%) * [k] (0014=01%) * [l] (0055=05%) ***** [m] (0032=03%) *** [n] (0061=06%) ****** [o] (0032=03%) *** [p] (0040=04%) **** [r] (0083=08%) ******** [s] (0062=06%) ****** [t] (0088=08%) ******** [u] (0048=04%) **** [w] (0018=01%) * [y] (0020=02%) **
If you run your completed LetterFrequency code with this text file: [PrimitiveStorage.txt], you should obtain this output: [counts.txt].
When finding the most frequently occurring letter, it is possible that more than one letter qualifies as most frequent. In this case, the first letter in the counted character range should be regarded as the most frequent.