Question: and crack Requirements In a file called Caesar.java , implement the following public static methods. a method called rotate that rotates a single character. It
and crack


Requirements In a file called Caesar.java , implement the following public static methods. a method called rotate that rotates a single character. It should have two arguments: an integer (int) shift and a char to rotate, and return the character rotated by the given shift, as a char. Lower-case characters should be translated into lower-case characters, capitalised ones into capitalised ones, and all other characters should remain untouched. another method called rotate that rotates a whole string. It should have two arguments: an integer (int) shift and a string to rotate and return the string rotated by the given shift, as a string - . a main method, that allows to encode/decode text, as follows. This should interpret the first two The first argument is interpreted as an integer shift and the second one as a (string) message to be rotated. The only output printed by the program should be the rotated string output. Moreover, the main method should check if it was called with exactly two arguments and complain otherwise. See below for example outputs. Your program needs to print the exact same output to be considered correct. $> java Caesar 3. "The ships hung in the sky in much the same way that bricks don't." Wkh vklsv kxqj lq wkh vnb lq pxfk wkh vdph zdb wkdw eulfnv grq'w. $> java Caesar -13 "The ships hung in the sky in much the same way that bricks don't." Gur fuvcf uhat va gur fxl va zhpu gur fnzr jnl gung oevpxf qba'g $> java Caesar 13 The ships hung in the sky in much the same way that bricks don't. Too many parameters! Usage: java Caesar n "cipher text" $> java Caesar 13 Too few parameters! Usage: java Caesar n "cipher text" 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
