What recommendations would you provide to the programmer on coding practices should have been used?
3. Random Sentences (Programming Challenge)
Create an application that produces random sentences as output. Create five arrays of strings, one each for nouns, adjectives, verbs, prepositions, and articles. Each array should hold several words of that part of speech. For example, the strArticles array could hold the strings “the” and “a”; the strNouns array could hold “Martian”, “baby”, “skunk”, “computer”, and “mosquito”; the strPrepositions array could hold “around”, “through”, “under”, “over”, and “by”; and so on.
The application should generate sentences by randomly choosing eight words (randomly generating eight array indices) from these arrays, always constructing sentences by using the parts of speech in the following order: article, adjective, noun, verb, preposition, article, adjective, noun. For example, a sentence might be “The shiny computer flew over a huge mosquito.” In this example, “The” and “a” were randomly chosen from the articles array, “shiny” and “huge” from the adjectives array, “computer” and “mosquito” from the nouns array, “flew” from the verbs array, and “over” from the prepositions array. Be careful to produce sentences that have the proper spacing, uppercase and lowercase letters, and a period at the end.
Design your form with buttons to display the next sentence, to clear all sentences currently displayed, and to close the application. Display your sentences, one per line, in a list box. Allow enough room to display at least 10 sentences. Figure 8-48 shows an example of the form using a list box. The figure shows the form with three
sentences generated.
———————————–x—————————–x—————————————–x————————————–x—————
Review the provided program/code document. If you wish to run & debug the program (I recommend it), a working program is also provided. Answer the following items using complete sentences and correct grammar and punctuation. For those of you who need extra incentive to complete this discussion, this counts toward your final grade.
- Identify any errors you find and state what is necessary to correct the error.
- What recommendations would you provide to the programmer on coding practices should have been used?
- What suggestions would you make to improve the program?