# In java write a command-line program that helps to decrypt a message that has been encrypted...

###### Question:

In java write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1. Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case) are encrypted – a constant number, the shift, is added to the ASCII value of each letter and when letters are shifted beyond ‘z’ or ‘Z’ they are wrapped around (e.g. “Crazy?” becomes “Etcba?” when shifted by 2).

When your program is correctly run, it will be provided two strings: the encrypted message and a string that is in the deciphered text. If fewer/more arguments are provided, your program is to output an error:

$java edu.wit.cs.comp1050.PA4a Please supply correct inputs: : <encrypted string> <substring>$ java edu.wit.cs.comp1050.PA4a a

Please supply correct inputs:  : <encrypted string> <substring>

$java edu.wit.cs.comp1050.PA4a a b c Please supply correct inputs: : <encrypted string> <substring> If the correct arguments are supplied, you are to output any shifts (00-25) that contain the supplied substring:$ java edu.wit.cs.comp1050.PA4a 'Jvtwbaly zjplujl pz mbu!' is

09: Secfkjuh isyudsu yi vkd!

19: Computer science is fun!

$java edu.wit.cs.comp1050.PA4a 'Jvtwbaly zjplujl pz mbu!' 'fun!' 19: Computer science is fun! If no shifts contain the substring, provide an error:$ java edu.wit.cs.comp1050.PA4a 'Jvtwbaly zjplujl pz mbu!' '?'

No valid shifts found.

To build this program in an object-oriented fashion, you must first implement a Shifter class. This class is constructed with the encrypted string, and then has methods to both shift by an arbitrary amount and find substrings across all shifts.

To implement this class in an efficient manner, you should use a StringBuilder to shift the encrypted string. You might also find it useful to use an ArrayList to accumulate an unknown number of valid shifts. Look to the JavaDoc’s of the String class for methods to search a string for a substring.

Here is the skeleton code for the Shifter class

public class Shifter {

/**

* Number of letters in the English alphabet

*/

public static final int NUM_LETTERS = ('z' - 'a') + 1;

/**

* Initializes the shifter

*

* @param s encrypted string

*/

public Shifter(String s) {

}

/**

* Returns the result of shifting

* by a supplied amount

*

* @param n number of places to shift

* @return shifted string

*/

public String shift(int n) {

return null; // replace with your code

}

/**

* Finds all shifts that contain

* the supplied substring

*

* @param sub substring to find

* @return array of shifts (0-25) that contain the substring (in order)

*/

public int[] findShift(String sub) {

return null; // replace with your code

}

}

Here is the main program skeleton:

public class PA4a {

/**

* Error if incorrect command-line arguments are supplied

*/

public static final String ERR_USAGE = "Please supply correct inputs: <encrypted string> <substring>";

/**

* Error if shift could not be found

*/

public static final String ERR_NONE = "No valid shifts found.";

/**

* Outputs all shifts of the encrypted string

* that contain the supplied substring

*

* @param args command-line arguments: <encrypted string> <substring>

*/

public static void main(String[] args) {

}

}

#### Similar Solved Questions

##### For a reservoir with the following data: → pore-volume compressibility is 17x10-6 psi-1 overburden pressure gradient...
For a reservoir with the following data: → pore-volume compressibility is 17x10-6 psi-1 overburden pressure gradient = 1 psi/ft > Pore pressure gradient = 0.5 psi/ft What is the percentage of porosity reduction for every 1000 feet increase in depth....
##### Please urgent electrical or mechanical engineer can help? I have 20 hours.I have to finish. Pleaseeee :(
Question 1) A $$380 \mathrm{~V} 60 \mathrm{~Hz}$$ two-pole three-phase asynchronous motor has a reverse power factor of 0.80. Stator resistance $$0,200 \Omega$$ rotor resistance $$0,120 \Omega$$ iron reactance resistance $$150 \Omega$$ friction andwind losses $$450 \mathrm{~W}$$, iron losses \(1500 ...
##### Case Study N.G. is a 21-year-old year-old college student who is admitted to the hospital with...
Case Study N.G. is a 21-year-old year-old college student who is admitted to the hospital with a diagnosis acute poststreptococcal glomerulonephritis. He was seen at the college's student neam center because of swelling around his eyes and rusty-colored urine. His history based on medical record...
##### Let 1 0 0 0 0 0 2 0 0 0 A=0 0 3 0 0...
Let 1 0 0 0 0 0 2 0 0 0 A=0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 (a) (5 points) Find the general solution to the sysem of equations I' = AT (b) (5 points) Solve the initial value problem x1(0) = x2(0) - = ... = C5(0) = 5....
##### Please need the correct answer and the rationales A nur se is cariną tor a client...
please need the correct answer and the rationales A nur se is cariną tor a client with hyperparathyroidism. The nurse identifies the most appropriate nursing intervention for this client? A) Pad side rails as a seizure pre caution B Increase fluid intake to 3-4L daily C)Maintain bedrest to ...
##### Discuss one drug of abuse and report it's impact on the patient's health
Discuss one drug of abuse and report it's impact on the patient's health...
##### For the reaction 2 HCl + Ca(OH), CaCl2 + 2H2O how many grams of calcium chloride,...
For the reaction 2 HCl + Ca(OH), CaCl2 + 2H2O how many grams of calcium chloride, CaCl2, are produced from 78.3 g of hydrochloric acid, HCI? mass of calcium chloride:...
##### Assume a function F(a,b,c) is 0 when abc-010 or abc=101, and is 1 when abc are...
Assume a function F(a,b,c) is 0 when abc-010 or abc=101, and is 1 when abc are otherwise. Which Karnaugh-map correctly describes set of prime implicants for a minimum sum-of-products for the function F? C ab ab ab 00 00 00 01 01 10 11 11 10 11 10 3 2 1 O 1 only 2 only 03 only Both 1 and 2 are correc...
##### Write formal report on impact of covid 19 on Domino's?
write formal report on impact of covid 19 on Domino's?...