Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE NEED HELP WITH THE CODING IN C++ Question #3: Manipulating variables of type 'string' (6 pts) Write a program that prompts the user for
PLEASE NEED HELP WITH THE CODING IN C++
Question #3: Manipulating variables of type 'string' (6 pts) Write a program that prompts the user for a word with an odd number of characters and code it based on the following specifications. To illustrate the coding, I will use the word "Nancy". Insert in between the 1st and 2nd character the character that follows the 1st character in the Unicode sequence. In "Nancy", the 1st character is 'N, which is followed by the character 'O. So the character 'O' is to be inserted between the 'N' and 'a' 1. 2. Replace the middle letter, which is the letter at position length()/2, by the character that is 2 after in the Unicode sequence. In "Nancy" the middle character is 'n'. This character wil be replaced by the character 'p' which is 2 characters after 'n'. Insert in between the second to last and last character, the character that is right before the last character in the Unicode sequence. In "Nancy", the last character is 'y' which is preceded by the character 'x'. So the character 'x' is to be inserted between the 'c' and the 'y'. The resulting coded word is "NOapcxy" 3. 4. Your program should: Display a welcome message. Prompt the user for his/her word with an odd number of characters which is then stores in a variable of type string. Echo back to the user the word entered, the 1st, middle and last characters of the word. Display the new 2nd letter, the new middle letter, and the new 2nd to last letter. Display the resulting coded word. Display a farewell message, so that the user knows that the program has terminated normally. 1. 2. 3. 4. 5. 6. Restrictions: No looping statements allowed (or needed). This questions requires the use of the functions: at(), length), substr( Assumption: Assume a perfect user who will always enter a word with an odd number of characters. Hint: Adding the integer 1 to a character results in the next character in the Unicode sequence. Following are three sample screen shots to illustrate the expected behavior of your program. Your program is to work with any word with an off number of characters entered by the user User input at the keyboard is marked with a red circle C:Windows system321cmd.exe Welcome to Nancy's Word Coder Enter a word with an ODD number of characters Nancy The word you entered is "Nancy" uhich has 5 characters The 1st character is 'N' The middle character is 'n' The last character is'y' After the coding process..- The new second character is 0' The new middle character is 'p The new before last character is x he resulting word is "NOapcxy" which has Mission characters. accomplished!!! Figure 4-Sample output #1 for Question 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started