Question: Create a program in C++ to encode and decode a message input by the user. 1. Let the user input a message which will consist
Create a program in C++ to encode and decode a message input by the user. 1. Let the user input a message which will consist of a string or an array of characters. 2. Save the original message in a variable called, original_message. 3. Create a function named encode to encode the message. The function will receive a pointer to the original message and return the string with the encoded message. 4. Create a variable named encoded_message to hold the return value from encode. 5. Create a function named decode to decode the message. The function will receive a pointer to the encoded message and return the string with the decoded message. 6. Create a variable named decoded_message to hold the return value from decode. 7. Test your program with the following strings: "Onomatopoeia", "Readability", "Abstraction & Polymorphism" "C++ is the Best!!" The output will look like the following, where the first # means the original message and the other two are the encoded and the decoded messages. Enter a string: ####### Encoded string: ####### Decoded string: #######
Expected output for each of the values required:
"Onomatopoeia": encoding: "Rprodvrrrhld" "Readability": encoding: "Thdfddlnlva" "OOP & Polymorphism": encoding: "RRR & Rrnaortrjluo" "C++ is the Best!! ": encoding: "E++ lu vjh Dhuv!! " "2004 !%^&*() ? ": encoding: "2004 !%^&*() ? "
Notes: The encoding/decoding will be done the following way: - Capital and lower case letters will be encoded the same way. - Consonants input will be shifted two positions. (Ex: b?d, h?j, p?r, x?z, z?b) - Vowels input will be shifted three positions (Ex: a?d, e?h, i?l, o?r, u?w) - Numbers and other special characters including blanks will remain untouched.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
