Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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) 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); Call this program3_strings.cpp. Submit program3_string.cpp to Blackboard in the Assignments Area before the due date and time. Only assignments submitted through Blackboard will be graded. 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 & s); 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;

}

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

Do you plan to interview employees when they resign?

Answered: 1 week ago

Question

1. Let a, b R, a Answered: 1 week ago

Answered: 1 week ago