Question: This is the part of main.cpp #include #include #include #include WordData.h using namespace std; int main() { cout // strtok is a string tokenizer, which
This is the part of main.cpp #include
int main() { cout
// strtok is a string tokenizer, which could be used to // break down a string into a number of substrings according // to the delimiter specified as the second argument. // Note: " " is the delimiter in this program // Attention!!! strtok_s is for Window User // Replace strtok_s(...) with strtok_r(...) if you're XCode user cstr = strtok_s(str," ", &nstr); //cstr = strtok_r(str," ", &nstr); // for XCode user while(cstr != NULL) { WordData word; string myStr(cstr); word.setWord(myStr); word.displayData(); cstr = strtok_s(NULL, " ", &nstr); //for Windows user // cstr = strtok_r(NULL, " ", &nstr); //for XCode user } return 0; } 

Part 2: Lab Task 1. 2. Create a New Project and give your project the name Lab9. In this lab, you are required to create a class Word Data that has the following features. A WordData object should be able to store a character string and a number of integers representing the number of vowels, the number of consonants, the number of digits and the number of special characters in the character string. It also consists of a number of functions to manipulate the data The UML class diagram is given below: WordData word : char* vowels : int consonants : int digits : int specialChars: int WordData() -WordData() setWord(const string& inWord): void getWord() const: string displayData() const : void + where word: a data member to store a string represented in character string vowels: a data member to store the number of vowels in "word" consonants: a data member to store the number of consonants in "word" digits: a data member to store the number of digits in "word" specialChars: a data member to store the number of special characters in "word" WordData(): a default constructor that sets the word to new char(11; with word[0] = *\0'; Also it sets all the remaining data members to 0. Note: "O' is a character, which represents the end of a character string. -WordData(): a destructor, which releases the memory allocated for "word" (More details about destructor will be given later in lectures!) setWord(const string& in Word): a mutator function that performs the following: a) Allocate memory space to store the string associated with in Word (You can use string member function "size()" to determine the length of in Word. Also, you are reminded to allocate memory space for the character, which should be put at the end of the string.) b) Count the number of vowels in in Word (a, e, i, o, oru) c) Count the number of consonants in in Word (letters that are not vowels) d) Count the number of digits in in Word (0, 1, 2, 3, 4, 5, 6, 7, 8, or 9) e) Count the number of "special characters" in in Word (characters that do not fall in any of the other categories) Note: The ASCII range of 'A' to 'Z' is 65 to 90, 'a' to 'z' is 97 to 122. range of "0* to "9 is 48 - 57. getWord(): an inspector function (a CONSTANT member function as well) that returns the character string as a CH string. Example to convert a char* to string: string str(charString); // where str is in string type, charString in char* type displayData(): an output function (a CONSTANT member function as well) that outputs a) Character string "word" b) All the other data members in one line. Note: TWO TABs must be added after displaying the character array, ONE TAB in between cach of the remaining data. 3. A main function (in main.cpp) has been provided for you to test out your class. The following is the sample output. Word Vowels Const. Digits Special 1 1 1 3 5 2 This string has 15 words. It has lots of letters and very few special chars! 1 1 1 1 2 1 1 1 3 1 0 4 1 2 3 1 5 2 3 2 4 4 OOOOOOOOOOOOOO! OOOOOOOOOOOOO
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
