Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an application that uses random-number generation to create sentences. Use

ID: 3644015 • Letter: W

Question

Write an application that uses random-number generation to create sentences. Use four arrays of strings called article, noun, verb and preposition. Create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article and noun. As each word is randomly picked, concatenate it to the previous words in the sentence. When the final sentence is output, it should start with a capital letter and end with a period. The application should generate and display 10 sentences. and output them into a text box.

The article array should contain the articles "the", "a", "one", "some" and "any".
The noun array should contain the nouns "boy", "girl", "dog", "town" and "car".
The verb array should contain the verbs "drove", "jumped", "ran", "walked" and "skipped".
The preposition array should contain the prepositions "to", "from", "over", "under" and "on".

after the precedong program is written modify the program to produce a short story consistiing of several of these sentences.

Explanation / Answer

using System; class Program { static void Main() { // String arrays with 5 elements: string[] art = { "the", "a", "one", "some", "any" }; // 1 string[] noun = { "boy", "girl", "dog", "town", "car" }; // 2 string[] verb = { "drove", "jumped ", "ran", "walked", "skipped" }; // 3 string[] prep = { "to", "from", "over", "under" ,"on" }; // 4 Random random = new Random(); int RandArt1 = random.Next(6); int RandNoun1 = random.Next(6); int RandVerb = random.Next(6); int RandPrep = random.Next(6); int RandArt2 = random.Next(6); int RandNoun2 = random.Next(6); string sentence = art[RandArt1] +" "+noun[RandNoun1]+" "+verb[RandVerb]+" "+prep[RandPrep]+" "+art[RandArt1] +" "+noun[RandNoun1]+"." string sentence2 = char.ToUpper(sentence[0])+sentence.Substring(1); Console.WriteLine(sentence2); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote