Question: Part 1 . Write a function that takes in an English sentence as one string. This function should first calculate how many words are in
Part Write a function that takes in an English sentence as one string. This function should first calculate how many words are in the sentence words being substrings separated by whitespace It should then allocate a dynamic array of size equal to the number of words. The array contains Word structures ie array of type Word The function would then store each word of that sentence to the English field of the corresponding structure. The function should then return this array to the calling function using the return statement, along with the array size using a reference parameter.
This function should also remove all capitalization and special characters other than letters. Implement the function with the following prototype
Word splitSentenceconst string words, int &size;
Part Write a function that takes in an array of Word structures and the size of the array and converts each English field to the corresponding BearCat form field.
void convertToBearCatWord wordArr, int size;
To do this conversion, if a word starts with a consonant, the bearCat conversion of the word involves moving the second letter of the word to the end of the string and then adding oi to the end.
pig pgioi
cat ctaoi
dog dgooi
If the word starts with a vowel, simply move that letter to the end and add yay to the end of the word
apple ppleayay
are reayay
Part Write a function that takes in an array of Word structures and outputs the BearCat form part of it to the screen, with each word separated by a space.
void displayBearCatconst Word wordArr, int size;
Example:
Please enter a string to convert to BearCat form:
Casino is nothing but a Goodfellas knockoff
Output:
csinoaoi siyay nthingooi btuoi ayay godfellasooi kockoffnoi
Error conditions: Your program should get rid of all punctuation and special characters other than letters. Your program should be able to deal with there being two or more spaces between words.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
