Professional Documents
Culture Documents
AegrotatTest 2017
AegrotatTest 2017
SECTION A (15)
Answer the following questions on the answer sheet that is provided.
The computer must be switched off while you are completing Section A.
This is not an open-book section.
4.1. Write code that will assign values to all the elements in A using the Next method of r
that takes no parameters and returns integers. (3)
4.2. Write code that will add 5 integers to B using the same method as in 4.1. (3)
4.3. Write code that will swap the last value in A with the last value in B. (3)
[15]
SECTION B (116)
Instructions
This is an open-book section (Section B). You may use the text book “Be Sharp with C#”
but no other sources, written or electronic, will be allowed.
1.1 Develop a console application and name your project Question 1. Your program
must be generic in the sense that a user must be able to enter any sentence and ask
for replacement of any word(s) with other(s). For instance, the application should
allow the user to replace all occurrences of "programming" with "coding" and "kids"
with "students". Note that there may be any number of words to be replaced.
1.2 Display the total number of replacements. For the example above, there are 2
replacements.
(18)
2. Develop a Windows Forms application and name your project Question 2. Create three
arrays of type double. Do a compile-time initialization and place any 10 doubles, each
rounded to one decimal place, in two of the arrays. The application should store the
product of the two arrays in the third array. Display the arrays in a list box as in the
example. Display all the numbers to two decimal places.
(16)
3. Develop a Windows Forms application and name your project Question 3. The
application should allow the user to enter and save animals’ (Reptiles or Mammals)
details.
3.3 Develop two sub-classes, CReptile and CMammal, that will inherit from
CAnimal. In both sub-classes, override the method SetAge. The methods should
enforce the rules that the age must be more than 0 and that Reptiles should not be
older than 3 years and Mammals should not be older than 5 years. If this is not true,
an age of 0 should be assigned and an appropriate message should be displayed.
(Hint: The MessageBox class is available in the System.Windows.Forms
namespace.) (12)
[116]
Submission Procedure
When you are ready to submit, add all your project folders to a single folder and rename that
folder to your student number. Submit a .zip archive of that folder under the Assessment
Archive / Sick Test link on Blackboard.