CST1620 C# Programming

Week 6

We cover chapter 7 in the book - Using Methods.

Watch the class lecture recording for the week. We do the in class exercise in the recording.


In class exercises:

Chapter 7 Exercise 10 (in class exercise) - example
Create a program named FlexibleArrayMethod that declares at least three integer arrays of different sizes. In turn, pass each array to a method that displays all the integers in each array and their sum.


Homework Labs:


Lab Chap 7 Exercise 10 FlexibleArrayMethod - due in one week

This was an in class exercise. Turn in what we did in class.

Submit three things to the D2L dropbox for this lab:
1) Screenshot of your running program with data. Make sure you capture your entire desktop.
2) Screenshot of as much of your code as possible.
3) The entire solution folder as a ZIP file. This folder should contain your entire project and solution..


Lab Chap 7 SentenceGeneration - due in one week

example

Write a program that uses random number generation to create sentences.  Use four arrays of strings called article, noun, verb and preposition 1pt. 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 picked, concatenate it to the previous words in the the sentence.  The words shall be separated by spaces.  The first letter of the sentence starts with a capital letter (do this by changing the first letter of the sentence to a capital letter) 1pt. The sentence ends with a period 1pt. Generate at least 20 sentences and output them to a Listbox.

Note: You must create a method in which most of your code resides 5pts. No need to pass in any parameters. The method contains the array declarations, the random number generation, and the sentence construction. A string (the completed sentence) is returned from the method.

The main program takes the string and adds it to the ListBox items 2pts.

Create a GUI (Winform or WPF). Your choice.

The arrays should be filled as follows:

article noun verb preposition
the boy drove to
a girl jumped from
one dog ran over
some town walked under
any car skipped on

Hint:
Example sentences would be:

One car jumped on the dog.
The girl ran under some car.

Submit three things to the D2L dropbox for each lab:
1) Screenshot of your running program with data. Make sure you capture your entire desktop.
2) Screenshot of as much of your code as possible.
3) The entire project folder as a ZIP file. This folder should contain your entire project and solution.