Your 7 year-old neighbor has just excitedly told you that she has discovered this really neat code which she and her friends are using to send messages to each other. The code, she explains, involves writing a number in place of each letter of the alphabet. The coding equivalences are:
A=1, B=2, C=3, D=4, E=5, Z=26 (your neighbor doesnt worry about lower case letters: she does everything in upper case).
In addition, they are using zero for each space between words.
Thus, a message such as HELLO WORLD would be encoded as: 8 5 12 12 15 0 23 15 18 12 4. For decoding, the numbers are to be entered with commas between them, so an encoded message such as 1,2,3,0,24,25,26 would be decoded as: ABC XYZ (space between C and X).
Your neighbor, however, says that it takes a really long time to translate her messages into code or to decode the messages she receives from friends, so she is wondering if you could write a computer program to do those jobs for her (and you have agreed!).
The screen should have an input field for the message and an output field for the result (this can be a text box or a div area). The functions are launched by button clicks using an Encode command button, a Decode command button, and a Clear command button. Remember that only upper case messages are processed, so all input in the message text box should be translated into upper case before processing (re-display the uppercase version of the message in the original box).
For Decoding, you will need to separate the values based on the comma as the delimiter; also note that input such as: 1, 2, 3 (with spaces after the commas) should not crash the system but should be treated as the equivalent to: 1,2,3
You will handle any characters or values outside the expected as follows: for Encoding, an unexpected character should return as the number 99; for Decoding, an unexpected number should return as a ? (question mark) in the final result.
The Clear button is the standard operation: clear the display areas and put the cursor in the input field.
You should review various string handling methods discussed in the text. Pay special attention to items such as length, charAt(), substr(), toUpperCase(), split(), etc.
Part A is the Encode function (and clear); Part B is the decode function.
A screen for this program with an Encode operation showing: see image.
And a Decode Operation: see image.
(you do not have to match the color scheme shown above do whatever you like).