SECTION A [20 Marks]
Question 1 (10 Marks)
Multiple Choice Questions
Write the correct letter next to the corresponding question number. Example: 1.1. a
1.1. yields the remainder after division
a. Modulus√√
b. Division
c. Integer Division
d. Binary division
1.2. Statements executed in sequence one after the other are called a -------------
a. Control sequence
b. Precedence sequence
c. Procedure
d. Sequence√√
1.3. Which assignment is correct in [Link]?
a. Dim money as double = 12;
b. Dim money as decimal = 12.0; √√
c. Dim money as integer = 12.0;
d. None of the above
1.4. A decision is based on a(n) value.
a. Boolean√√
b. Absolute
c. Definitive
d. Convoluted
1.5. Executes a set of statements until its loop termination condition becomes true.
a. Do while loop
b. Do until loop√√
c. For loop
d. For next loop
Question 2 (10 Marks)
True and False Questions
Indicate whether the following statements are true or false.
Choose the answer and only write true or false next to the corresponding question number.
2.1. When using the radio button control, you should always have at least two radio buttons on
the form.
2.2. You must use a group box when using check box controls.
2.3. A compound condition using the logical operator AND will be true if either of the individual
conditions are true.
2.4. You cannot specify the icon that appears on a message box.
2.5. It is not possible to discard unwanted user input.
2.6. The percentage sign (%) is the concatenation operator.
2.7. In an arithmetic expression, multiplication will take place before addition.
2.8. The SetFocus method will move the focus to a control at run time.
2.9. The Text property specifies the text that will appear in the title bar of the form
2.10. Constants store values that may change during program execution.
2.1. True√
2.2. False√
2.3. False √
2.4. False√
2.5. False√
2.6. False √
2.7. True√
2.8. False √
2.9. True√
2.10. False √
Question 3
3.1. Briefly define the following terms (10)
3.1.1. Nested selection structure- a selection structure that is wholly contained (nested)
within either the true or false path of another selection structure.
3.1.2. Data validation- the process of verifying that a program’s input data is withinthe
expected range. √√
3.1.3. Single-alternative selection structure- a selection structure that requires a special
set of actions to be performed only when the structure’s conditionevaluates to
True. √√
3.1.4. Data type- indicates the type of data a memory location (variable or named
constant) can store. √√
3.1.5. Scope- indicates where a memory location (variable or named constant) canbe
used in an application’s code. √√
3.2. Identify and briefly explain 3 types of errors. (6)
• Logical error√ -These are human errors. Logical errors occur when a program
does not perform the way it was intended to do. Program runs but produces
incorrect results. √
• Syntax error√- breaking the rules of the programming language. Syntax errors are
the most common errors in any programming language. E.g. Misspelling a word. √
• Runtime error√ -Very common in arrays, runtime error occurs when a programmer
allocates less memory for a given application than what the applications needs.
Program executes but stops when an error is found. E.g. Division by zero. √
Question 4
4.1. Complete the code given below (10)
Dim intJack As Integer
Dim intMary As Integer
Dim intKate As Integer
Dim intPeter As Integer√
Dim intTotal As Integer
[Link]([Link], intJack)
[Link]([Link], intMary)
[Link]([Link]√, intKate)
[Link]([Link], intPeter) √
intTotal = intJack + intMary + intKate + intPeter√
[Link] = intTotal√.ToString("C0")√
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles [Link]
Dim response As String
response√ = [Link]("Are you sure you want to exit?", "Exit",
[Link], [Link])
If response = vbYes√ Then
[Link]()√
End If√
End Sub
Question 5
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles [Link]
[Link]()√
End Sub
Private Sub btnAssign_Click(sender As Object, e As EventArgs) Handles [Link]
' calculates the total points earned, then displays
' the total points earned and the appropriate grade.
Dim strAnotherStudent As String√
Dim strInputPoints As String√
Dim intPoints As Integer√
Dim strGrade As String√
Dim intAccumulator As Integer√
Do√
[Link] = [Link]√
[Link] = [Link]√
' get and accumulate the points on 3 tests
intAccumulator = 0√
For intCounter As Integer = 1 To 3√√
strInputPoints = InputBox("Enter the points earned on test " &
[Link], "Grade Calculator", "0")√√
[Link](strInputPoints, intPoints) √
intAccumulator = intAccumulator + intPoints√
Next intCounter√
' assign grade
Select Case intAccumulator√ Case
Is >= 270√
strGrade = "A"√Case
Is >= 240√
strGrade = "B"
Case Is >= 210√ strGrade
= "C"√
Case Is >= 180√
strGrade = "D"√
Case Is >= 150√
strGrade = "E"√
Case Else√
strGrade = "F"√
End Select√
'display the total points earned and the
grade [Link] =
[Link]√
[Link] = strGrade√
strAnotherStudent = InputBox("Another student?", "Grade
Calculator","Y")√Loop While [Link] = "Y"√√
End SubEnd Class
√√√√√ marks for comments
√√√√√ marks for interface