Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Caesar cipher shifts letters in a string. It is proposed to write a Caesar cipher program that can enter and acrypt a non-empty word

image text in transcribed

A Caesar cipher shifts letters in a string. It is proposed to write a Caesar cipher program that can enter and acrypt a non-empty word M, composed only by capital letters and display the encrypted word MC. The encryption process is the following: a. For each letter, determine the number of occurrence in the word M. For this. Write a method int Occur(string Mchar c) that calculate and return the number of occurrence of c in the string M. b. Write the method int Calculate (int n) that determine the value of K and return it. Where K is equal to 2 +n if n is odd and will be equal to (n % 2) if n is even. c. Replace each letter by Kth letter which follows it in the interval of the alphabet ['A... Z] Write the method char Encrypt (charc, int k) which returns the kth letter following c in the alphabet. For example if K = 3, ifc='A' then the return value is D (wich is A+3). If c = B the return will be 'E', ... Attention for the last letters, if c ='Y and K = 3. the return value will be B and forc="Z, the retum will be 'C. d. Write the main method that allow to ask the user to enter a stringM then encrypt and display the encrypted string by calling the above methods Example of Execution: Enter a Word: HAPPY The Encrypted word is: JCQQ4 "H' 'A' 'p 'P "Y 1 1 2 2 1 Number of occurence The value of K The encrypted letter 1'2=2 1'2=2 2 DIV 2=12 DIV 2=1 1*2=2 'C' Q 'Q' 'A

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions