Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. Write a C + + program that does the following: a . Create a C + + file with the name lab 1 3

. Write a C++ program that does the following:
a. Create a C++ file with the name lab13_3.cpp.
b. 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.
c. Write the main function that does the following:
i. 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.
ii. Prompt the user for a positive integer, validating the input until the user enters a positive integer.
iii. Call the function bookEndString passing into it the string and the integer.
iv. Print the modified string.
Sample run of the program:
Enter a word with at least three letters: hi
Invalid input! Enter a word with at least three letters: hello
Enter a number greater than 0: 0
Invalid input! Enter a number greater than 0: 3
The modified word is: ZZZhelloZZZ
Sample run of the program:
Enter a word with at least three letters: shoes
Enter a number greater than 0: 4
The modified word is: ssssshoesssss

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions