CST1620 C# / C++
Programming
Lab Week 6
Exercises |
||||||||||||||||||||||||||||||||
Exercise 7.1 Sentence
Generation (10 points) Write a program 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 picked, concatenate it to the previous words in the the sentence. The words should be separated by spaces. When the sentence is output, it should start with a capital letter and end with a period. The program should generate 20 sentences and output them to a Listbox. The arrays should be filled as follows:
Hint: One car jumped on the dog.
|
||||||||||||||||||||||||||||||||
Exercise 7.5 Array List
(10 points) Use a single-subscripted array to solve the following problem: Input 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print a message stating if the number is a unique number or that it is a duplicate of a number already entered. Provide for the "worst case" in which all 20 numbers are different. Use the smallest possible array to solve this problem (the array size is 20 elements). Notes: I will be checking that you reject any numbers that are not 10 to 100 inclusive. I will check that you stop accepting after reading 20 numbers. Result (Save to your local machine and run)
|
||||||||||||||||||||||||||||||||
Exercise 15.4 Transpose
EC (Extra Credit 10 points) The transpose of an array is the technical term used to describe swapping the elements in an array across one of the diagonals. The numbers on the diagonal do not change. So if an array is:
then its transpose is:
Write a program to input the elements of an array in the same manner as the rainfall program. It transposes the array when a button is clicked, and displays it.
|