Professional Documents
Culture Documents
INSTRUCTIONS TO CANDIDATES
Test 2
QUESTION 1
Write an event procedure starting with cmdCompute_Click() and having one line for each
step
a) The following steps calculate the amount of work done by a force moving a body a
certain distance in the direction of the force
i. Assign the value 160 to the variable force
ii. Assign the value 14 to the variable distance
iii. Assign the product of force and distance to the variable work
iv. Display the value of the variable work
(5 marks)
lblDisplay
cmdCompute
lblDisplay.Text = Work
End Sub
QUESTION 2
The Customer’s Water Bill System: Program description: The bill includes a $35.00 water
demand charge plus a consumption (use) charge of $1.10 for every thousand gallons used.
Consumption is figured from meter reading (in thousands of gallons) taken recently and at
the end of the previous quarter. If the customer’s unpaid balance is greater than zero, a
$2.00 charge is assessed as well. DRAW A FLOWCHART BASED ON ALGORITHM BELOW;
a. Get data: unpaid balance, previous and current meter reading.
b. Compute use charge.
c. Determine applicable late charge.
d. Figure bill amount: water bill = demand charge + use charge + unpaid balance +
applicable late charge.
e. Display the bill amount and charges.
Use suitable variables in your flowchart.
(10 marks)
Get data
:Unpaid balance,
previous and
current meter
reading
Compute new
charge
Determine
applicable late
charge
Display bill
amount and
charges
End
QUESTION 3
Sketch the user interface and name all of the controls in the interface. Then, write the
codes for a procedure to solve the problems given below.
Problem: Request three numbers as input and then calculate average of the
three
(10 marks)
lblNum1
lblNum2
lblNum3
btnCalculate
txtNum1
lblResult
txtNum2
txtNum3
num1 = txtNum1.Text
num2 = txtNum2.Text
num3 = txtNum3.Text