Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Y ou are the owner of this Work Sign store that sells signs including individual letters made of plastic that customers would buy to put

You are the owner of this "Work Sign" store that sells signs including individual letters made of plastic that customers would buy to put on their mailboxes such as the "5793 Dowling" street address in the following picture:

Your shop is so popular everyone in town comes to your store to buy sign letters. But your inventory of plastic letters is limited. Sometimes you have them in stock. Sometimes you don't.

You want to write a class that automatically determine whether a set of mailbox signs (or street addresses) is possible given your available plastic letter inventory in the store. Your console program MUST include this class declaration with the member function:

class CIS14 { public: int getNumPossibleSigns(string* letterInventory, string* addresses, int length); };

In addition the member function documentation is as follows:

/** * MEMBER FUNCTION NAME: * getNumPossibleSigns * PURPOSE: * The function takes in a series of addresses in a string array and compares each of them with the available * letterInventory, returning the number of addresses that are POSSIBLE to form from the given letterInventory * PARAMETER:  * string* letterInventory * string* addresses * int length: length of the array, addresses[] * RETURN VALUE:  * int: the number of possible addresses that can be formed from your inventory of letters */
 

Note the length parameter in the function. Assuming your addresses[] is as follows:

 std::string addresses[] = {"S1","S2","S3"}; 

Then you may obtain the length of your C++ string array using the sizeof():

 int length = sizeof(addresses)/sizeof(addresses[0]);

Example #1:

"AAAABCCC123456789"

{"123C","123A","123 ADA"}

Returns: 2

Only two of these can be formed. The space in "123 ADA" can never be a problem, and collection contains two 'A's. We only consider one address at a time so it doesn't matter that we cannot form both "123C" and "123A" at the same time from this collection. The two possible signs that can be formed from this collection are "123C", "123A"

Example #2:

"ABCDEFGHIJKLMNORSTUVWXYZ1234567890"

{"2 FIRST ST"," 13 PUN ST", "101 AKER"}

Returns: 0

We cannot form any of these. The first address requires two 'S's, the second address requires a 'P', and the third address requires two '1's.

Example #3:

"ABCDAAST"

{"999 S ST", "A BAD ST", "B BAD ST"}

Returns: 1

"999 S ST" cannot be formed since collection does not contain any digits. "B BAD ST" cannot be formed because it requires 2 'B's.

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

What do you love most about life?

Answered: 1 week ago

Question

How can you defend against SQL injection attacks?

Answered: 1 week ago