In this part of the assignment, you will code a ciphering program. A cipher is an algorithm for performing encryption or decryption of messages. We will use a cipher algorithm that I have devised called step cipher.

Task # 1: Write a method called encode that will encode a message using a specified key that is in the range 0 through 25. The header of the method should be as follows:

public static String encode(String message, int key)

The message may include spaces and punctuation characters, but only the lower case characters 'a' through z should be encoded.

Each of the letters of the alphabet will map to the letter key positions further along in the alphabet. For example, if the key value is 4, the letters of the alphabet will be mapped as follows:

A -> E
B -> F
C -> G

and so on...

Task # 2: Write a function that will decode a message using a specified key that is in the range 0 through 25. The header of the method should be as follows:

public static String decode(String codedText, int key)

The coded text may include spaces and punctuation characters, but only the lower case characters 'a' through z should be decoded.

You may not use StringBuilder to solve this problem.

All code needs to be sufficiently commented.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.