For years, the Radio Orphan Annie's Secret Society has entrusted their members with special Little Orphan Annie decoder pins so that they can decode secret messages from Orphan Annie. For this program, the system of decoding messages will be modernized so that a C++ program can do the decoding rather than having to rely on a physical pin.
The information to be decoded is contained in a text file. The file will be processed one character at a time. Each character will be decoded by calling an appropriate function and then the decoded character will be displayed
Heres what I have so far but I keep getting a compiler error and I'm stuck. Any hel p would be greatly appreciated!!
After fixing this, I get reasonable output except that some of the punctuation looks wrong. If you post a description of how the encryption/decryption is supposed to work, we might be able to diagnose that problem.
Any character in message that was an uppercase character was converted to lowercase and then had 1 subtracted from it. So 'B' became 'a', 'C' became 'b', ... The first uppercase letter was the exception to the rule. The 'A' was simply wrapped around to the end of the alphabet so that it became 'z'.
Any character in message that was a lowercase character was converted to uppercase and then had 1 added it. So 'a' became 'B', 'b' became 'C', ... The last lowercase letter was the exception to the rule. The 'z' was simply wrapped around to the beginning of the alphabet so that it became 'A'.
Any character in message that was a digit ('0' ... '9') was converted as follows:
'0' --> )
'1' --> !
'2' --> @
'3' --> #
'4' --> $
'5' --> %
'6' --> ^
'7' --> &
'8' --> *
'9' --> (
Any character in message that was one of the following punctuation characters was encoded as shown below. Any punctuation that is not shown here was not altered.
, --> '9'
" --> '8'
! --> '7'
; --> '6'
? --> '5'
' --> '4'
( --> '3'
) --> '2'
. --> '1'
- --> '0'
Two white space characters were encoded as non-standard characters:
a blank/space was encoded as an ASCII 22
a newline character was encoded as an ASCII 20
Do you know what the supposed out is ?
I made a few changes and got the following output:
*Be sure to drink your Ovaltine!*
*Aunt Clara had for years labored under the delusion that I was not only
perpetually years old( but also a girl!*
*Immediately( my feet began to sweat as those two fluffy little bunnies
with a blue button eye stared sappily up at me!*
*He looks like a deranged Easter Bunny!*
*HO! HO! HO!*
*The snap of a few sparks( a quick whiff of ozone( and the lamp blazed
forth in unparalleled glory!*
*Oh( look at that& Will you look at that% Isn$t that glorious% It$s!!!
it$s!!! it$s indescribably beautiful& It reminds me of the Fourth of July&*
*Randy( how do the little piggies go%*
*It is a lamp( you nincompoop( but it$s a Major Award! I won it&*
*Yeah( mind power( Swede^ mind power!*
*The line waiting to see Santa Claus stretched all the way back to Terre
Haute! And I was at the end of it!*
*Football% Football% What$s a football% With unconscious will my voice
squeaked out $football$!*
*Okay( get him out of here!*
*A football% Oh no( what was I doing% Wake up( Stupid& Wake up&*
*No& No& I want an Official Red Ryder Carbine)Action Two)Hundred)Shot
Range Model Air Rifle&*
*You$ll shoot your eye out( kid!*
*Of course! Santa! The big man! The head honcho! The connection! Ha( my
mother had slipped up this time!*
*With as much dignity as he could muster( the Old Man gathered up the
sad remains of his shattered major award! Later that night( alone in
the backyard( he buried it next to the garage! Now I could never be sure(
but I thought that I heard the sound of *Taps* being played( gently!*
*Grover Dill& Farkus$s crummy little toadie! Mean& Rotten& His lips
curled over his green teeth!*
*Don$t you touch that& You were always jealous of this lamp!*
*What is the name of the Lone Ranger$s nephew$s horse%*
*Ah!!! Victor& His name is Victor!*
*The heavenly aroma still hung in the house! But it was gone( all gone&
No turkey& No turkey sandwiches& No turkey salad& No turkey gravy&
Turkey Hash& Turkey a la King& Or gallons of turkey soup& Gone( ALL GONE&*
To test your program, I modified it to create decode(char ch) whose job is to decode any character, and decodeString(), which takes an encoded string and then prints the string as well as the decoded string. Finally, I modified main() to call decodeString() with different type of strings. When I run it, I see that it's decoding punctuation characters wrong. Fix this program until it decodes correctly, then replace main() with a version that reads and decodes the file.
$ ./foo
from: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
to: "zabcdefghijklmnopqrstuvwxy"
from: "abcdefghijklmnopqrstuvwxyz"
to: "BCDEFGHIJKLMNOPQRSTUVWXYZA"
from: "0123456789"
to: ")!@#$%^&*("
from: "!@#$%^&*()"
to: "732"
from: ""
to: ""
from: ""
to: ""