Question: This assignment will access your C++ language skills. After completing this assignment, you will be able to do the following: (1) prompt a user for

This assignment will access your C++ language skills. After completing this assignment, you will be able to do the following: (1) prompt a user for input, (2) write output to the screen and (3) use the string class Write a program that have two functions: 1. A boolean function called palindrome that accepts one string argument and returns true if the string reads the same forward as it does backwards. For example, madam, 463364, and ABLE WAS I ERE I SAW ELBA, are all palindromes.

2. A function called replace_all that accepts three string arguments, old_substring, new_substring, and original_string. The function will return a copy of string original_string with each occurrence of old_substring replace by new_substring. original_string is not changed. For example is original_string = aaabbacceeaaa, old_substring = aa, and new_substring = zzz, the function will return the string zzzabbacceezzza. Consider the following prototypes for the functions: bool palindrome(constr string s); string replace_all(const string & original_string, const string & old_substring, const string & new_substring);

Please use substr and find. Call this program3_strings.cpp. Consider the following skeleton to help you implement your program: ////////////////////////////////////////////////////////////////////////////////////////////

//Remember to include a program header

///////////////////////////////////////////////////////////////////////////////////////

#include

#include

using namespace std; bool palindrome(const string &);

string replace_all(const string & original_string, const string & old_substring, const string & new_substring);

////////////////////////////////////////////////////////////////////////////////////////////

//Remember to include a function header

//Function name:

//Precondition

//Postcondition

//Description

///////////////////////////////////////////////////////////////////////////////////////

bool palindrome(const string & s)

{

//your code goes here

return true;

} ////////////////////////////////////////////////////////////////////////////////////////////

//Remember to include a function header

//Function name:

//Precondition

//Postcondition

//Description

///////////////////////////////////////////////////////////////////////////////////////

string replace_all(const string & original_string, const string & old_substring, const string & new_substring)

{

string s;

//your code goes here

return s;

} int main()

{

//driver should have a loop prompting user for input. For example, (1) user wants to run the function palindrome or

//replace_all and (2) prompt the user for the appropriate input once the function has been determine (one string for

//palindrome and 3 for replace_all).

return 0;

}

Please use substr and find.

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!