Question
The Problem Caesar's cipher is a simple and old substitution encryption technique, typically using a three letter left shift - and a great way to
The Problem
Caesar's cipher is a simple and old substitution encryption technique, typically using a three letter left shift - and a great way to learn about manipulating elements in arrays! We want to be able to read in text from a user, and either encrypt or decrypt it with our cipher - so not only can we make secret messages, but we can crack them too!
Make a Java program that is simply made using Variables, Console I/O, Java Program Design, Intro to IDEs, If Statements, Selection and Conditional Logic, Strings, Loops, Nesting, and Iteration, Arrays - Single and Multidimmensional. It doesn't have to use all of them, but the whole program can only use things from this list--nothing too advanced, only what a beginner would use from the list.
It will do the following things:
- Asks a user if they would like to encrypt or decrypt their text. You may choose whatever you'd like the user to input to make their choice (letters, strings, etc), but you need to be able to distinguish between the choice to encrypt or the choice toe decrypt, and to let the user know what they should type to make that choice. - Ask the user to enter the text they want to encrypt or decrypt (based on their choice above). - Take the text in, and then place the user text into an array. - Enact the proper shifting on the array elements to complete the cipher. For encryption, we shift 3 letters backward - for decryption, we shift 3 letters forward. If a letter is on the edges, like A and Z, we should wrap around - think of the alphabet as a circle. Only letters should shift - punctuation is fine to stay as it is!
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW
Lowercase versions match result, but are lowercased!
- Bri's hint: pull out an ASCII chart! Look at the possible values for letters, and think about what decisions you need to make when wrapping to get your values to line up correctly. - After you've completed your cipher shifts, move the array elements back together as a String. - Display the result to the user!
~~EXAMPLES OF EXPECTED CIPHER RESULTS~~
Encrypt: Hello! Encrypted Result: Ebiil!
Decrypt: -Zljm Pzf- Decrypted Result: -Comp Sci-
Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD
NOTE:
Remember Strings contain character values, which are denoted by ' ', not " ", and also have an integer based representation!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started