Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please implement a function that accepts a string parameter, two character parameters as well as a boolean parameter. If the string parameter is the empty

Please implement a function that accepts a string parameter, two character parameters as well as a boolean parameter. If the string parameter is the empty string, set the boolean argument to false. Otherwise, your function should return the number of times it finds each character parameter inside the string. It these two counts are equal, set the boolean argument to true. Otherwise, set that boolean argument to false. The declaration for this function will be:

void hasThatManyOfThis( string s, char thatCharacter, char thisCharacter, bool & answer );

Here are some examples of how a main routine could test this function:

bool b = false;

hasThatManyOfThis( "", 'Z', 'A', b ); // the string parameter is the empty string assert( b == false );

hasThatManyOfThis( "HelloWorld", 'Z', 'A', b ); // zero A's and zero Z's found in the string assert( b == true );

hasThatManyOfThis( "HelloWorld", 'H', 'W', b ); // one H's and one W's found in the string assert( b == true );

hasThatManyOfThis( "HeolloWorld", 'l', 'o', b ); // three l's and three o's found in the string assert( b == true );

hasThatManyOfThis( "HeolloWorldooo", 'l', 'o', b ); // three l's and six o's found in the string assert( b == false );

Write your hasThatManyOfThis function in the text box below. You do not have to write a main routine or #include directives.

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 Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions

Question

Recognize your typical method of resolving conflict.

Answered: 1 week ago