Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please 6.45 Caesar Cipher Today you will be decoding secret messages. We will be using Caesar Cipher, that was used by Caesar (the roman

C++ pleaseimage text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

6.45 Caesar Cipher Today you will be decoding secret messages. We will be using Caesar Cipher, that was used by Caesar (the roman politician and military general) to pass messages to his army. It is a shift cipher which works by shifting the positions of the text. For example if you had to encrypt the word ocean by shifting the alphabets by 5: we would shift 'o' by 5 to get 't', 'c' by 5 to get 'h' and so on. So the word, Plain Text: **ocean** Shifted Text: **thjfs**, Cipher : shift by 5. Where we can assume if plaintext to cipher map as below for shift by 5: Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher: FGHIJKLMNOPQRSTUVWXYZABCDE Shifting by 5 means alphabet A becomes alphabet Fie. A the first alphabet becomes the (1+5=6) alphabet F, and so on. HINT: The alphabets wrap so that A comes after Z. Shifting thjfs by 21 gives you Shifted Text: ocean Running the program looks like: Enter some lower-case text: hello Shifting 0 gives: hello Shifting i gives: ifmmp Shifting 2 gives: jgnng Shifting 3 gives: khoor Shifting 4 gives: lipps Shifting 5 gives: mjggt Shifting 6 gives: nkrru Shifting 7 gives: olssv Shifting 8 gives: pmttw Shifting 9 gives: qnuux Shifting 10 gives: rovvy Shifting 11 gives: spwwz Screenshot Shifting 12 gives: taxxa Shifting 13 gives: uryyb Shifting 14 gives: VszZc Shifting 15 gives: wtaad Shifting 16 gives: xubbe Shifting 17 gives: yvccf Shifting 18 gives: zwddg Shifting 19 gives: axeeh Shifting 20 gives: byffi Shifting 21 gives: czggj Shifting 22 gives: dahhk Shifting 23 gives: ebiil Shifting 24 gives: fcjjm Shifting 25 gives: gakkn But, we have given you text that is shifted like thjfs from the above example. You have to shift the letters to read what it says. We have given you the main. You will write your code in the functions. Step 1: (Point 1) Write the function ?? shiftThetext(???), supply the parameters and the return type. Step 2: (Point 1) The function shiftTheText() will shift each alphabet given by the shift integer Given an array of characters and a shift value, shift each character in the original text by some amount, storing the result into the shifted Text array Wrap around at the end of the alphabet (like in the plaintext to cipher mapping A appears after 2). Running the test for Stage 2: only one of the output will make sense. (See example below: Shifting 17 gives: hello) Enter some lower-case text: qnuux Shifting 0 gives: qnuux Shifting 1 gives: rovvy Shifting 2 gives: spwwz Shifting 3 gives: taxxa Shifting 4 gives: uryyb Shifting 5 gives: vszzo Shifting 6 gives: wtaad Shifting 7 gives: xubbe Shifting 8 gives: yvccf Screenshot Shifting 9 gives: zwddg Shifting 9 gives: zwddg Shifting 10 gives: axeeh Shifting 11 gives: byffi Shifting 12 gives: czggj Shifting 13 gives: dahhk Shifting 14 gives: ebiil Shifting 15 gives: fcjjm Shifting 16 gives: gdkkn Shifting 17 gives: hello Shifting 18 gives: ifmmp Shifting 19 gives: jgnng Shifting 20 gives: khoor Shifting 21 gives: lipps Shifting 22 gives: mjgqt Shifting 23 gives: nkrru Shifting 24 gives: olssv Shifting 25 gives: pmttw Step 3: (Extra credit Points 1) Write a mystery function, that will be called from the function shiftTheText(). It will perform a mystery task it changes the shifted Text so that it is readable in English. HINT: To understand what the mystery task is, check each line of output, check which is readable. HINT: Do as the message says. LAB ACTIVITY 6.45.1: Caesar Cipher 0/2 | main.cpp Load defaut templat. Load default template... 1 / cipher.cpp 2/ CS 141 Lab 3 / 5 5 * Running the program looks like: Enter some lower-case text: hello Shifting 0 gives: hello Shifting 1 gives: ifmmp Shifting 2 gives: jgnng Shifting 3 gives: khoor Shifting 4 gives: lipps Shifting 5 gives: mjgqt Screenshot 35 #include 36 #include 37 #include 39 using namespace std; 41 // Global constants 42 const int MaxWordSize = 81; // 80 characters + 1 for NULL 43 44 //Uncomment for stage 3 45 //The mystery function changes shiftedText so that it is readable and not gibberish). 46 // *** In the line below you must supply the function return type and the parameter(s) *** 47 // void mystery (??) { 48 // } 49 50 53 //----- 54 // Given an array of characters and a shift value, shift 55 // each character in the original text by some amount, 56 // storing the result into the shiftedText array. 57 // Wrap around at the end of the alphabet. 58 // *** In the line below you must supply the function return type and the parameter(s) *** 59 ? shiftTheText() 60 { 62 // Loop through each character in the startingText until '\0' is reached. // For each character, if it is in the range 'a'.. 'z' then shift it by // adding the shift Value. Store the resulting character into the corresponding // position in the shiftedText array. 68 } // end shiftTheText() 74 //-------- 75 int main() 74 //-------- 75 int main() 76 // Initialize the variables char startingText[ MaxWordSize]; char shiftedText[ MaxWordSize]; cout startingText; tyalue 20e stof basis the starting text array, the shift valu for( int shiftValue = 0; shiftValue

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

Step: 3

blur-text-image

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago