guyinNeed wrote: |
---|
thank you for commenting on my post, however, i am still a little confused about how to solve the problem. is your recommendation going towards
if ( userInput.at(0) >= 'a' && userInput.at(0) <='z')) ?? |
No...
The map is a 1-to-1 lookup table. Normally the alphabet is ordered like this:
"abcdefghijklmnopqrstuvwxyz"
If you were to use that as your lookup table, you'd get for output the same thing you gave as input, because 'a' --> 'a', 'b' --> 'b', etc.
The default lookup table is:
"zyxwvutsrqpomnlkjihgfedcba"
If you put them together you see the relationship:
abcdefghijklmnopqrstuvwxyz
zyxwvutsrqpomnlkjihgfedcba |
That is, 'a' --> 'z', 'b' --> 'y', etc.
Now, assume the user enters, for input, "fghjkl".
abcdefghijklmnopqrstuvwxyz
fghjkl |
Notice something missing?
('a' --> 'f', 'b' --> 'g', etc, but what does 'g' --> ?)
You need to either:
(1) Require the user to enter 26 letters exactly (no less), or
(2) Automatically fill-in the missing letters.
For method two, consider the consequence of using the letters "fghjkl":
abcdefghijklmnopqrstuvwxyz <-- letters available
- fgh jkl <-- letters used
----------------------------
abcde i mnopqrstuvwxyz <-- letters not used |
Having removed the used letters, we can stick the unused ones at the end of the user's input.
"fghjkl" + "abcde" + "i" + "mnopqrstuvwxyz" --> "fghjklabcdeimnopqrstuvwxyz"
Now there is a proper mapping:
abcdefghijklmnopqrstuvwxyz
fghjklabcdeimnopqrstuvwxyz |
Hope this helps.