Question: Please help me write this Java program. I had posted this question before, but got an answer that was totally wrong. We are using the

Please help me write this Java program. I had posted this question before, but got an answer that was totally wrong. We are using the latest version of Java8. Thank You!

--------------------------------------------------------------------------------------

Write a Java program that can successfully DECRYPT a string inputted by the user which has been encrypted using a Caesar Cipher with a unknown shift value(key).

You can use brute force to do a for loop through all the 26 shift values, however, your program should only return the CORRECT decrypted string and not all the other incorrectly decoded strings.

Your program should be case sensitive and should include the foreign characters (such as commas, puncuation marks, etc.) as they were located in the encrypted text. You are to only decrypt the letters of the alphabet (a-z), all other characters should stay as they are. Your program should work for all shift values up to and including 26, and then print the correctly decoded string.

--------------------------------------------

An Example run would be:

--------------------------------------------

Enter Encoded Text: Czxafepc Sntpynp, td lmzgp lww, esp rcplepde! Decoded Text is: Computer Science, is above all, the greatest!

-------------------------------------------

Another Example run would be:

--------------------------------------------

Enter Encoded Text: Iw yv yru repkyzex tfewzuvekzrc kf jrp, yv nifkv zk ze tzgyvi, kyrk zj, sp jf tyrexzex kyv fiuvi fw kyv cvkkvij fw kyv rcgyrsvk, kyrk efk r nfiu tflcu sv druv flk. Decoded Text is: If he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!