[solved]-Write C Application Uses Random Number Generation Create Sentences Use Five Arrays Strings Q39011713
Write an C++ application that uses random-number generation tocreate sentences. Use only five arrays of strings called article,noun, verb and preposition. All words in each array should use onlylower-case letters. The length of each array should not be thesame, and should be determined by the program when the programruns. Create a sentence by selecting a word at random from eacharray in the following order: article, adjective, noun, verb,preposition, article, adjective and noun. As each word is randomlypicked, concatenate it to the previous words in the sentence. Whenthe final sentence is output, it should start with a capital letterand end with a period. It is the program that needs to capitalizethe first word of each sentence. The application should generateand display 20 sentences.
The article* array should contain at least thewords “the”, “a”, “one”, “some” and “any”.
The adjective array could contain words like”brave”, “orange”, “fast”, “slow”, etc.
The noun array could contain words like “boy”,”girl”, “dog”, “town”, “car”, etc.
The verb array could contain words like “drove”,”jumped”, “ran”, “walked”, “skipped”, etc.
The preposition array should contain at least”to”, “from”, “over”, “under” and “on”.
*NOTE: Articles the, a andan are only used with singular nouns. Do not worryabout selecting either ‘a’ or ‘an’ based on whether the next wordstarts with a vowel. The words some andany are actually classified as ‘determiners’ inthe English language and can be used with plural nouns.
You can change or add additional nouns, adjectives, verbs andprepositions to the arrays. Make sure that your random picker looksat the array size for each type of part of speech.
Examples:
The brave dog skipped to a fast town.
The orange car jumped over a slow dog.
A fast girl walked to a brave girl.
==================================================================================================================================
==================================================================================================================================
// sample program for noun only
#include <iostream> // needed for printf#include <cstdlib> // needed for the random number generator#include <ctime> // needed to seed the random number generator#include <cctype> // needed for toupper()#include <string> // needed for C++ stringsusing namespace std;const char * noun[] ={ “desk”, “chair”, “envelope”, “car”, “train”, “bus”, “boat”, “elephant”, “dog”, “cat”, “moose”, “rabbit”};int nounCount = sizeof(noun)/sizeof(char*);int main(int argc, const char * argv[]){ // declare the variables string sentence; // C++ string object int selection; srand( (unsigned int)time(0) ); // seed the random number generator for (int i=0; i<5; i++) // create and display 5 sentences { // put in a noun selection = rand()%nounCount; // pick a noun sentence = noun[selection]; // use = to place the 1st word in thesentence sentence += ” “; // use += to add a space after each word selection = rand()%nounCount; // pick a noun sentence += noun[selection]; // use += to add another word to sentence sentence += ” “; // use += to add a space after each word sentence[0] = toupper(sentence[0]); // make 1st char capital letter cout << sentence << endl; // display the sentence } return 0;}
// end of the sample program
thank you so much!!!
Expert Answer
Answer to Write an C++ application that uses random-number generation to create sentences. Use only five arrays of strings called … . . .
OR

