Question: Write a program to create random sentences. Read from an input file that contains article, nouns, verbs, and prepositions. An example input file: 10 Articles

Write a program to create random sentences. Read from an input file that contains article, nouns, verbs, and prepositions. An example input file:

10

Articles 5

the a one some any

Nouns 5

boy girl dog town car

Verbs 5

drove jumped ran walked skipped

Prepositions 5

to from over under on

The first integer in the file (10 in the example) specifies the number of sentences to generate. The rest of the input file has sections for each part of speech (your code needs to handle these being in any order). The first string will specify the part of speech (Articles in the example) and an integer specifying the number of that type of word that is on the next line (5 in the example). You may assume no word in the file is over 75 characters long. The words given for each part of speech are to be stored in a dynamically allocated array of strings (a jagged 2D array). Thus assuming the input file above, an array called articles would look like this: t h e \0 a \0 o n e \0 s o m e \0 a n y \0 Each of these arrays (articles, nouns, verbs, prepositions) should be displayed in alphabetical order (implement your choice of sorting algorithm). After the arrays are set up and sorted, generate the random sentences and display them numbered. Example output (you do not have to match this format): A sentence is of the form: article noun verb preposition article noun. Capitalize the first letter and add an exclamation point to the end. You need to store the sentence in a dynamically allocated string, perfectly fit for the sentence

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!