JOMO KENYATTA UNIVERSITY OF AGRICULTURE AND
TECHNOLOGY
University Examinations 2022/2023
YEAR II SEMESTER I SUPPLEMENTARY EXAMINATION FOR THE DIPLOMA IN
INFORMATION TECHNOLOGY
DIT 0303: PROGRAMMING DESKTOP APPLICATIONS
DATE: MARCH 2023 TIME: 1½ HRS
INSTRUCTIONS: Answer ANY THREE Questions
QUESTION ONE
a) Consider the program below
Module Module1
Sub Main()
// Program to compute the sum of even numbers between
21 and 40
Dim x=21 sum As integer =0
Do
If(x=< 20 && x>40) Then
Console.ReadLine(“Out of range”)
Else
If(x%2==0) Then
Sum+=x
x++
End If
End If
Console. Write(“Sum = & sum”)
End Sub
End Module
Identify the errors and write correct code. [7 marks]
b) Describe all the arithmetic operators supported in VB.NET, showing the operation each
performs and discuss their precedence. [8 marks]
c) Write a property that makes field mark Write-only and ensure only a mark between 0 and
100 is captured. [5 marks]
QUESTION TWO
a) Before a patient is treated, preliminary diagnosis on blood pressure and body mass index is
done and the status given as shown below.
Blood Pressure Status Systolic(mmHg) Diastolic (mmHg)
Normal <120 <80
Elevated 120-129 <80
Hypertension Stage 1 130-139 80-89
Hypertension Stage 2 140-180 90-120
Critical >180 >120
BMI value Status
<18.50 Underweight
18.50-24.99 Normal
25.00-29.99 Overweight
>30 Obese
Given that BMI=weight(kg)/height (m2), write a console application that uses module
Patient to capture systolic and diastolic readings, weight and height of a patient then output
both patient’s Blood Pressure and BMI status. Your application should use a procedure to
capture the details, another to determine both blood pressure and BMI status, and a final one
that prints the output.
[15 marks]
b) Explain the role of the following .NET framework layers [5 marks]
i) Common Language Specification
ii) Common Language Runtime
iii) Base Class Library
iv) Data & XML
v) User Interfaces & Web Services
QUESTION THREE
a) Write code segments performing each of the following tasks.
i) Change the color of Form to blue. [2 marks]
ii) Set the title of Form to “Registration”. [2 marks]
iii) Populate a combo box with values 1,2,3,4,5. [3 marks]
iv) Make a textbox accept multiple lines. [3 marks]
b) Write a program that capture and store height of 13 students, then determine the average
height, the shortest student and the tallest student. [10 marks]
QUESTION FOUR
a) Suppose you want to develop a program to play lottery. The program randomly generates a
lottery of a two-digit number, prompts the user to enter a two-digit number, and determines
whether the user wins according to the following rules:
If the user input matches the lottery number in the exact order, the award is KSh.
10,000.
If all digits in the user input match all digits in the lottery number, the award is
KSh. 3,000.
If one digit in the user input matches a digit in the lottery number, the award is
KSh. 1,000.
Write a program implementing this requirement. [12 marks]
b) Explain the difference between the following pair of terms as used in VB.NET. [8 marks]
i) Polymorphism and Encapsulation
ii) Object and Class
iii) Sub and function procedures
iv) Constructor and garbage collection