This assignment is worth 75 points.
Each line in the file begins with a letter indicating the type of coding to apply. If additional parameters are required, they are given immediately after the code letter with the message following. Each message is terminated by the end of the line. There are an arbitrary number of messages in the file.
The code types supported are summarized in the table below.
Code Letter | Additional Arguments | Description |
---|---|---|
R | none | ROT 13 (see wikipedia). Rotate each letter by 13. Care should be taken not to exceed the range of a signed character. |
C | int | Caesar cypher ( see wikipedia) Argument will be between -25 and 25. Shift each letter (one at a time) by the given amount, but keep the result a letter. Shifting A by -1 yields a Z. |
I | none | Use the ICAO encoding scheme given on page 236 of the book, to each alphabetic letter. In addition encode the character ' ' to the word space |
i | none | Inverse ICAO encoding. Convert all words in the ICAO table to the corresponding letters. In addition, decode the word space to the character ' '. |
A | none | ASCII encoding. For each character in the line, convert the character to the corresponding ASCII value. Place a space between each distinct number (not digit) |
a | none | Inverse ASCII. Read in a series of valid integers and print the corresponding ASCII characters. Each number (not digit) will be delimited by spaces. |
B | 2 characters. | Binary. Print the corresponding ASCII value as a 7 bit binary number. The two characters represent the encoding value for 1 and 0 respectively. |
b | 2 characters | Binary Decode. Given a sequence of 7 character words, encoded in binary with 1 represented by the first argument and 2 represented by the second argument, print the corresponding ASCII characters. |
R Hello World! R Uryyb Jbeyq! C 5 Hello World! C -5 Mjqqt Btwqi! I Hello World! i HOTEL echo lima lima oscar space WHISKEY oscar romeo lima delta ! A Hello World! a 72 101 108 108 111 32 87 111 114 108 100 33 B T F Hello World! b T F TFFTFFF TTFFTFT TTFTTFF TTFTTFF TTFTTTT FTFFFFF TFTFTTT TTFTTTT TTTFFTF TT FTTFF TTFFTFF FTFFFFT X bad code letter
Will produce the following output:
Uryyb Jbeyq! Hello World! Mjqqt Btwqi! Hello World! HOTEL echo lima lima oscar space WHISKEY oscar romeo lima delta ! Hello World! 72 101 108 108 111 32 87 111 114 108 100 33 Hello World! TFFTFFF TTFFTFT TTFTTFF TTFTTFF TTFTTTT FTFFFFF TFTFTTT TTFTTTT TTTFFTF TTFTTFF TTFFTFF FTFFFFT Hello World! Unknown code letter X NOT ENCODING bad code letter
Your identifiers should be constructed properly, with meaningful names.
You should document your code with comments.
Your output should be organized, easy to read, and make appropriate use of white space.
Your program should report an error message if the file is not available.
Your program should preserve the case of letters in the messages. For ICAO, an upper case letter is represented in all caps, for example A will encode as ALPHA, and a will encode as alpha.
For ICAO, a space should be encoded as the word space
Your program should always work. If it encounters an error, it should recover and continue.
You should report errors, such as unknown Code Letters.
All parameters will be supplied and will be in the correct format.
There will always be a space between the code letter or last parameter and the message. This space should not be part of the message.
All messages will consist of at least one character.
Start on this program early. It is not difficult, but it does require quite a bit of code.
You may not use string streams for this program.
When decoding a binary string, assume any letters that don't match the code letter given for one are zeros. (In the above example, T = 1, F = 0, the word XXXXXX1 = FFFFFFT).