I can't figure out how to set up most of the program for this. Here is the assignment:
Description
Write a program that allows the user to enter any number of strings that will then be encoded, decoded and then displayed to the console. The program should request that the user enter a string to be encoded or ‘X’ (both X and x should work) to quit. The user will continue to enter strings, which you will immediately encode and store in the array, encodedData. When ‘x’/’X’ is entered, the program should then display all of the strings entered first in their decoded form, then their encoded form
(should appear right beneath the decoded string; see sample run below). Each row of data should be numbered, starting with 1.
Encoding
Encoding should be done within a function called encode, which receives a string (raw data) and returns a string
(encoded data). All keyboard characters, including white space, should be accepted and encoded, with the
exception of our terminal value X/x. Each string is really just an array of characters, so you can loop through
each string variable from 0 to yourStringVarName.length() and examine and encode one character at a time.
Before you can start the encoding process, you will need to convert the character to its ASCII value,
which is the (int) value of a character. Our encoding algorithms will be numerically based.
The first alteration will be that each letter‘s ASCII value should decrease by three. This value (3 or -3,
depending on how you write the code) should be stored in a constant. This variable should be used
within the code, not the hard-coded number three.
The second alteration will be that each odd (being in position 1, 3, 5, etc.) character’s ASCII value should
be increased by five. The number five should be stored in a constant. This variable should be used
within the code, not the number five.
You will need to reverse this process to decode.
You will need an array of strings called encodedData in which you will store the encoded string value returned from your encode function. You will not store the raw data entered by the user—only the encoded string. You will need to give the array a size when it’s declared, and you can use a value (CONSTANT) of 20. This is the
maximum number of strings that can be stored in your array. Alternately you could use a vector to store the encoded data rather than an array, in which case you can just add “rows” as you go.
Decoding
Decoding should be done within a function called decode, which receives a string (encoded data) and returns a
string (decoded data).
Would someone help me by showing me an example of how this works? I got as far as this in the attachment.