Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Problem E Problem Time to flex those coding muscles (often referred to as a brain, though not scientifically proven to be true, but we

image text in transcribedJava Problem

E Problem Time to flex those coding muscles (often referred to as a brain, though not scientifically proven to be true, but we digress...) on the final problem for this worksheet. For this problem, you are going to be implementing a classic Caesar cipher. If you aren't familiar with the cipher, you can find a detailed explanation here. Essentially, the Caesar cipher encodes a String (the plaintext) by choosing an arbitrary constant from 1-26, and shifting each letter of the alphabet across that many spaces. As an example, if the shift value was 3, then to encode a String we would replace A with D, B with E, C with F, and so on. With the same value, to decode a String we would replace A with X, B with Y, C with Z, and so on. Your program will continue to ask for user input until ended with Control+D or Command+D, or the keyword "Stop". The inputs to your program are: direction, a String, one of "Encode" or "Decode", indicating whether you are converting from plaintext to ciphertext, or vice versa, or the value "Stop" to indicate your program should end n, the value to shift the text, between 1 and 26 (inclusive) text, the text to be encoded or decoded . . . After these inputs, your code must remove spaces from text (you may assume there will be no punctuation) and convert to upper case, then output the result of converting text, according to the direction value and the value of n. Examples of the code executing: Encoding/Decoding? Stop Encoding/Decoding? Encode Enter n: 5 Enter text to convert: Zephyr Bird ZEPHYRBIRD EJUMDWGNWI Encoding/Decoding? Decode Enter n: 5 Enter text to convert: EJUMDWGNWI EJUMDWGNWI ZEPHYRBIRD Encoding/Decoding? Once you get your code working, play around with the cipher and see how it works. You should notice that it's not a very hard code to decipher by hand. One of the downfalls of this cipher is that it is very deterministic; shifting characters by 5 spaces is the same as shifting it by 3, and then shifting the new ciphertext by 2 more. Once we learn arrays, we'll revisit this encryption scheme and improve it. Note You may assume that all inputs will be valid, so don't worry about writing input validation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago