Question: You are provided with a file called Brutus.java , which already defines letter frequencies in English texts. This is given as array of doubles, in


You are provided with a file called Brutus.java , which already defines letter frequencies in English texts. This is given as array of doubles, in alphabetical order: public static final double[] english = { 0.0855, 0.0160, 0.6316, 0.6387, 0.1210, 6.0218, 0.0209, 0.0496, 0.6733, 0.0022, 0.0081, 0.6421, 0.0253, 0.0717, 0.0747, 0.0207, 0.0010, 0.0633, 0.0673, 0.0894, 0.0268, 0.0106, 0.0183, 0.0019, 0.0172, 0.0011 }; Requirements In Brutus.java , write a method called count that takes a single String parameter and returns a length-26 integer array whose values reflect how often each character occurred. You should not make a difference between upper and lower case letters and the returned array should be in alphabetical order. This way, if letter Counts is an array resulting from your method then letterCounts [25] is the number of times the letter "z" or "Z" occurs. a method called frequency that takes a single String and returns a length-26 array of double s whose values correspond, in alphabetical order, to the frequency of the letter. This way, if letter Freq is an array resulting from this method then letter Freq[24] is the number of times the letter "X" or "X" occurs, divided by the length of the string input. a method called chiSquared, which returns the x-score (a double ) for two given sets of frequencies. That is, it should take two parameters, both of type double[] , and return a single double value that tells us how close these two arrays are. You may assume that the two inputs are always of length 26. a main method that can be used to decipher Caesar-encoded English cryptotext without the key. Of course, you should be using your chiSquared method as well as the given English letter frequencies. The string that is to be deciphered should be read from the first command line argument and your program should ensure that it gets exactly this one argument and complain otherwise. Sample output below. $> java Brutus "Vg vf n zvfgnxr gb guvax lbh pna fbyir nal znwbe ceboyrzf whfg jvgu cbgngbrf." It is a mistake to think you can solve any major problems just with potatoes. $> java Brutus Too few parameters! Usage: java Brutus "cipher text" $> java Brutus Too Many Parameters Too many parameters! Usage: java Brutus "cipher text
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
