Write a program that decodes a message that was encoded


For each the following programs, ensure you use the file names identified, comment in an appropriate manner, format your code appropriately (vertical and horizontal whitespace... aka. blank lines and tabs), and use good/appropriate variable names. You should expect the user to always type appropriate input (e.g., not words when a number is requested).

Decoding a secret message

Write a program that decodes a message that was encoded using a random key. These keys work similar to a magic decoder wheel (where 'A' encodes to 'F', 'B' encodes to 'G', 'C' encodes to 'H', etc)except there is a random mapping from one letter to another...

alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ
random key BDALJIFVKZEQRUXWYNTCMSGPOH

plain message encodded message
CRACKER ANBAEJN

You job is to read in a file named "encoded.txt" that contains 3 lines:

1. the random key (all uppercase)

2. the number of characters in the message (this will never be as high as 100, so an array of 100 characters will be a perfect variable to read the message into, one character at a time)

3. the encoded message (mixed case AND with punctuation and whitespace)

Your program should print the decoded message to the screen, but it should retain the upper or lower case-ness of each letter of the encoded message and print anything that isn't a letter as-is... that way the whitespace and punctuation are retained.

Here's an example encoded.txt for you to test with...
JHTIPBWNFRVDGUCZSLKYOEXQAM
82
Icu'y hp bccdpi ha ynp lctvk ynjy F wcy... F'g roky, F'g roky Jgck blcg ynp hdctv.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write a program that decodes a message that was encoded
Reference No:- TGS01248525

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)