Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

continuing explanation from original post from Friend. [Task 4] Caesar's Code is one of the simplest encryption techniques. Each letter in the plain text string

continuing explanation from original post from Friend.

[Task 4] Caesar's Code is one of the simplest encryption techniques. Each letter in the plain text string is replaced by a letter some fixed number of position (n) down the alphabet cyclically. For example, if we pick n=3, then 'A' is replaced by 'D', 'B' by 'E', 'C' by 'F', ..., 'X' by 'A', ..., 'Z' by 'C'. Write a class called CaesarCode to convert plain text string into a cipher text, encoded using Caesar Code. CaesarCode constructor should two inputs: N: Indicates the number of positions to shift the input text by inputText: an input consisting of mix-case letters only

The program uses the following strategy for case sensitivity and special symbols Case Sensitivity: Maintain Case Special Symbols: Ignore

The class should have a function which outputs the cipher text encoded using Ceaser Code logic.

Hints 1. Use in.next().toUpperCase() to read an input string and convert it into uppercase to reduce the number of cases. 2. You can use a big nested-if with 26 cases ('A'-'Z'). But it is much better to consider 'A' to 'W' as one case; 'X', 'Y' and 'Z' as 3 separate cases. 3. Take note that char 'A' is represented as Unicode number 65 and char 'D' as 68. However, 'A' + 3 gives 68. This is because char + int is implicitly casted to int + int which returns an int value. To obtain a char value, you need to perform explicit type casting using (char)('A' + 3). Try printing ('A' + 3) with and without type casting.

Write a JAVA class called TestCeasarCode to test the Caesar's code class written earlier. This class should have the main method for CaesarCode. The program shall prompt user for an input text string consisting of mix-case letters only; call the class to convert the text to Ceaser Coded ciphertext, and print the ciphertext. It will then pass the output to the CaeserCode class with the correct value of N to test if the program is written correctly. Enter a plain text string: Testing$ The ciphertext string is: Whvwlqj // Now pass the ciphertext string again to the class CeaserCode, with the //correct value of N The plaintext string is: Testing

Note, you must figure out the correct value of N to pass to the class during the second task of converting cipher text to plain text.

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions