You are on page 1of 5

CONFIDENTIAL - 1 -1 IS 110/MARCH 2008/IMD 152

UNIVERSITI TEKNOLOGI MARA


TAKE HOME TEST 2

COURSE : CONCEPT OF PROGRAMMING

COURSE CODE : IMD 303


EXAMINATION : MARCH 2008

INSTRUCTIONS TO CANDIDATES

1. This question paper consists of two (3) questions :

2. Answer ALL questions.

Name: Nor Safina Binti Mohd Radi


Metric No.: 2005193297
Group: DIM 5B

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO

This examination paper consists of 2 printed pages

© Hak Cipta Universiti Teknologi MARA


CONFIDENTIAL - 2 -2 IS 110/MARCH 2008/IMD 152

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

Private Sub cmdCompute_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdCompute.Click
Dim Force As Double = 160
Dim Distance As Double = 14
Dim Work As Double = Force * Distance

lblDisplay.Text = Work

End Sub

© Hak Cipta Universiti Teknologi MARA


CONFIDENTIAL - 3 -3 IS 110/MARCH 2008/IMD 152

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)

© Hak Cipta Universiti Teknologi MARA


CONFIDENTIAL - 4 -4 IS 110/MARCH 2008/IMD 152

Answer for Question 2 Start

Get data
:Unpaid balance,
previous and
current meter
reading

Compute new
charge

Determine
applicable late
charge

Water bill = demand


charge ($35.00) +
use charge ($1.10) If unpaid
+ unpaid balance balance = >0
($0) + applicable Then bill +
late charge ($0) $2.00

Figure bill amount

Display bill
amount and
charges

End

© Hak Cipta Universiti Teknologi MARA


CONFIDENTIAL - 5 -5 IS 110/MARCH 2008/IMD 152

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

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnCalculate.Click
Dim num1 As Double
Dim num2 As Double
Dim num3 As Double
Dim result As Double

num1 = txtNum1.Text
num2 = txtNum2.Text
num3 = txtNum3.Text

result = (num1 + num2 + num3) / 3


lblResult.Text = result
End Sub

© Hak Cipta Universiti Teknologi MARA

You might also like