Question: Create a C + + file with the name problem 3 . cpp . Write the function bookEndString, which has a string s and an

Create a C++ file with the name problem3.cpp.
Write the function bookEndString, which has a string s and an integer r as parameters, permanently modifying the string s. If the first and last letters of the string are the same, then add r copies of that letter to the beginning and ending of the string. Otherwise, add r Z's to the beginning and ending of the string. The return type for this function is void.
Write the main function that does the following:
Prompt the user for a string containing at least 3 letters, validating the input until the user enters a string with at least 3 letters.
Prompt the user for a positive integer, validating the input until the user enters a positive integer.
Call the function bookEndString passing into it the string and the integer.
Print the modified string.

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 Programming Questions!