Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions