Question: I need help figuring out this C++ code. See instructions below: The scaffold code below accepts written descriptions of whitespace from the user and sets

I need help figuring out this C++ code.

See instructions below:

I need help figuring out this C++ code. See instructions below: The

scaffold code below accepts written descriptions of whitespace from the user and

The scaffold code below accepts written descriptions of whitespace from the user and sets the value of the variable named separator accordingly. For example, if the user enters the string "newline the program will assign the value " " to separator. (This is done for the following input values: "tab", "space", "newline", and "null") Your assignment is create a new variable, called outputString, which uses the variable named separator in order to produce a poem that is formatted according to the desires of the user. The text of the poem you will use can be seen in the examples below. Each line of the poem should be followed by the escape character indicated by the user input. So if the user entered "newline", the lines of the poem should be separated by new lines, if the user entered "tab" the lines of the poem should be separated by tabs, and so forth. Sample Input newline Sample Output Roses are red Violets are blue I love to write code I hope you do too! Sample Input space Sample Output Roses are red Violets are blue I love to write code I hope you do too! Sample Input null Sample Output Roses are redViolets are blueI love to write code I hope you do too! Special Requirements Graded by TAS You must declare and use a variable named outputString (5 points) No "hard-coding' allowed. Specifically, you may not output different copies of the poem in different parts of the program. Just set the value of outputString once, and then display it to the user via cout. (20 points) You must adhere to the style guidelines (except the requirement to use endl instead of ). main.cpp Load default template... 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 string userInput; 7 cin >> user Input; 8 9 // NOTE: 10 // The code on lines 16 - 25 may seem confusing because it 11 // uses commands we haven't learned about (yet) in Zybooks. 12 // That's okay! Programmers are often asked to build off of 13 // code they did not write and do not completely understand. 14 15 // Set the value of separator based on user input 16 string separator; 17 if (userInput == "newline") { 18 separator = ' '; 19 } else if (userInput == "space") { 20 separator 21 } else if (userInput == "tab") { 22 separator = 'It'; 23 } else if (userInput == "null") { 24 separator = '\0'; 25 } 26 27 //TODO: create a variable named outputString 28 that contains a formatted copy of 29 the poem shown in the example output 30 31 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!