0% found this document useful (0 votes)
21 views11 pages

Midtest Q

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views11 pages

Midtest Q

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

FACULTY OF COMPUTING

MIDTERM TEST-ANSWER SCHEME


COURSE : PROBLEM SOLVING
COURSE CODE : BCI1143 / DCI1013
LECTURER : AWANIS BINTI ROMLI
MOHD ZAMRI BIN OSMAN
NOOR AZIDA BINTI SAHABUDIN
SALWANA BINTI MOHAMAD @
ASMARA
YUSNITA BINTI MOHD NOOR
ZURIANI BINTI MUSTAFFA
ZAFRIL RIZAL BIN M. AZMI
DURATION : 2 HOURS
SESSION/SEMESTER : SESSION 2020/2021 SEMESTER I
PROGRAMME CODE : BCS BCG BCN DCS

INSTRUCTIONS TO CANDIDATE:

1. This question paper consists of ONE (1) question.

EXAMINATION REQUIREMENTS:

NONE

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

This examination paper consists of THREE (3) printed pages including the front page.
QUESTION 1
Due to pandemic problem of COVID 19, Bantuan Prihatin Elektrik (BPE) is an additional
assistance package provided by the Government of Malaysia with TNB to all domestic
customers. Domestic customers who use electricity between 601 - 900 kWh per month will gain
a 10% discount (existing 2% discount rate + additional 8%) from April 2020 to September 2020.
The discount rates enjoyed by residential (domestic) customers are based on the total monthly
electricity consumption as shown in Table 1. Table 2 shows the block tarif rate and the values
are constant. Figure 1 shows a sample of customer’s bill. Discount BPE is total discount receive
by customer. Total usage is the total bill before discount and the total payment is the total bill
after discount.
Table 1: Discount Rate
Amount of Usage Total Bil Discount
1 - 200kWj (RM0.22 - RM44.00) 50%
201 - 300 kWj (RM68.34 – RM102.00) 25%
301 - 600 kWj (RM156.52 – RM312.00) 15%
601 - 900 kWj (RM402.67- RM603.00) 2% + *8%
>900 kWj (RM765.00 and above) 2%

Table 2: Block Tarif Rate


Block Tarif Rate (RM)
1 - 200kWj 0.22
201 - 300 kWj 0.34
301 - 600 kWj 0.52
601 - 900 kWj 0.67
>900 kWj 0.85

Account No: 225245


Customer Name: Abdullah bin Osman
Address: No. 25, Lorong 1, Taman Setia, Kg. Selamat, 63320 Pekan, Pahang.
Bill Date: 15 June 2020
Amount of usage (kWj) 750 Discount rate: 2%+ 8% = 10%
Total usage RM 502.50
Discount BPE RM X
Total payment: RM Y
Figure 1: Customer’s Bill
a) Based on the case study, construct a PAC, IC and IPO for the given problem. [35Marks]

2
Answer:
PAC

Given Data [1.75M] Required Result [2.25M]

Account No, Account No,


Customer Name, Customer Name,
Address, Address,
Bill Date, Bill Date,
Amount of Usage (kWh), Amount of Usage,
Discount Rate, Discount Rate
Block Tarif Rate (constant) Discount BPE
Total Usage
Block Tarif Rate (RM)
Total Payment
1 - 200kWj 0.22
201 - 300 kWj 0.34
301 - 600 kWj 0.52
601 - 900 kWj 0.67
>900 kWj 0.85
Processing Required Solution Alternative

If AmountofUsage <=1 and <= 200 then i. Define the given data as
DiscountRate = 0.5 constants.
Else If AmountofUsage >=201 and <= 300 then ii. *Define the given data as
DiscountRate =0.25 input values [1M]
Else if AmountofUsage >=301 and <= 600 then
DiscountRate =0.15 [5M]
Else if AmountofUsage >=601 and <=900 then
DiscountRate =0.1
Else
DiscountRate =0.02
EndIf
Total_Usage = AmountofUsage * BlockTarifRate [0.5M]
Total_Payment = Total_Usage – (Total_Usage * DiscountRate)
[1.5M]

3
IC: [3M]

CalcTotalBillControl
0000

Read Calculate Print


1000 2000 3000

IPO:
Input [1.25M] Processing Module Output [4.5M]
[2M]
AccountNo, 1. Enter AccountNo Read (1000)
CustomerName, 2. Enter CustomerName Read (1000)
[2.5M]
Address, 3. Enter Address Read (1000)
BillDate, 4. Enter BillDate Read (1000)
AmountofUsage 5. Enter AmountofUsage Read (1000)
6. If AmountofUsage <=1 and <= 200 then
DiscountRate = 0.5
7. Else If AmountofUsage >=201 and <= 300 then
DiscountRate = 0.25
8. Else if AmountofUsage >=301 and <= 600 then
DiscountRate = 0.15
9. Else if AmountofUsage >=601 and <=900 then
DiscountRate = 0.1
10. Else
DiscountRate = 0.02
11. Calculate Total_Usage = AmountofUsage * Calculate
BlockTarifRate [0.75M] (2000)

4
12. Calculate Total_Payment = Total_Usage – Calculate
(Total_Usage * DiscountRate) [1.5M] (2000)
13. Print AccountNo Print (3000)
AccountNo,
14. Print CustomerName Print (3000)
CustomerName
15. Print Address [2.5M] Print (3000)
Address,
16. Print BillDate Print (3000)
BillDate,
17. Print AmountofUsage Print (3000)
AmountofUsage,
18. Print Discount Rate Print (3000)
DiscountRate,
19. Print Discount BPE Print (3000)
DiscountBPE,
20. Print Total_Usage Print (3000)
Total_Usage,
21. Print Total_Payment Print (3000)
Total_Payment
22. End CalcTotalBi
llControl
(0000)
b) Identify variables, constant and data type for each of the item: [10Marks]
Variables [5Marks] Data type [5Marks]
AccountNo String
CustomerName String
Address String
BillDate String / Date
AmountofUsage Int
DiscountBPE Float
Total_Usage Float
Total_Payment Float
Constant Data type
BlockTarifRate Float
DiscountRate Float

5
c) Based on the custmer’s bill as in Figure 1, solve the calculation of total payment with an
amount of usage is 750 kWj and total usage is RM 502.50 by following the hierarchy of
operations. Total payment = A, Total usage = B, Discount (2%) = C, Discount (8%) = D.
[5Marks]
A = B – (B * (C+D))
Answer:

A = B – (B * (C+D))

3
4

No Operation [2Marks] Resultant [3Marks]


1 C+D 10/100

2 B* resultant of 1 50.25

3 B – resultant of 2 452.25

4 Store the resultant of 3 in the


memory location called A

d) Write an algorithm with decision logic for the given problem. [15 Marks]

Answer:
1. CalcTotalBill ( )
2. Enter AccountNo
3. Enter CustomerName
[3M]
4. Enter Address
5. Enter BillDate
6. Enter AmountofUsage
7. If AmountofUsage <=1 and <= 200 then
8. DiscountRate = 0.5
9. Else If AmountofUsage >=201 and <= 300 then
10. DiscountRate = 0.25

6
11. Else if AmountofUsage >=301 and <= 600 then
12. DiscountRate = 0.15 [5M]
13. Else if AmountofUsage >=601 and <=900 then
14. DiscountRate = 0.1
15. Else
16. DiscountRate = 0.02
17. EndIf
18. Calculate Total_Usage = AmountofUsage * BlockTarifRate [1M]
19. Calculate Total_Payment = Total_Usage – (Total_Usage * DiscountRate) [1M]
20. Print AccountNo
21. Print CustomerName
22. Print Address
23. Print BillDate
24. Print AmountofUsage
25. Print Discount Rate [5M]
26. Print Discount BPE
27. Print Total_Usage
28. Print Total_Payment
29. End

e) Draw a flowchart for the algorithm. [15 Marks]

Start [0.5M]
A

Enter AccountNo, [1M]


CustomerName, [2.5M]
Address, BillDate, V
AmountofUsage Calculate Total_Usage = AmountofUsage *
BlockTarifRate

[1M]
AmountofUsage T DiscountRate =0.5
<=1 and <= 200? Calculate Total_Payment = Total_Usage –
(Total_Usage * DiscountRate)
F

[4.5M]
AmountofUsage T DiscountRate =0.25 Print
V
>=201 and <= 300?
7
AccountNo,
CustomerNam
e, Address,
F BillDate,
[0.5M]

Processing 2.5M
Decision 2M
Line / True / False 0.5

8
Trace the logic of the algorithm by executing desk checking using the set data in Figure 1 and Block Tarif Rate in Table 2. [20
Marks] [5.5M]
V

No Accoun Customer Address BillDate Amount Discount TotalUsage TotalPayment Condition I/O
tNo Name of Usage Rate

1.

2. “22524 AccountNo? “225245”


5”
3. “Abdullah CustomerName?
bin “Abdullah bin Osman”
Osman”
4. “No. Address? “No. 253,
253, Lorong 1, Taman Setia,
Lorong Kg. Selamat, 63320
1, Pekan, Pahang”
Taman [5M]
Setia,
Kg.
Selamat,
63320
Pekan,
Pahang”
5. “15/06/2 BillDate? “15/06/2020”
020”
6. 750 AmountofUsage? 750
7. AmountofUsag
e <=1 and <=
200? F
9. AmountofUsag
e >=201 and
<= 300? F
11. [2M] AmountofUsag
e >=301 and
<= 600? F
13. AmountofUsag
e >=601 and
<=900? T
14. 0.1
[0.5M]
18. 750*0.67= [1M]
502.50

19. 502.50-
(502.50*0.1) = [1.5M]
452.25

20. “225245”
21. “Abdullah bin Osman”

22. “No. 253, Lorong 1,


Taman Setia, Kg.
Selamat, 63320 Pekan,
[4.5M] Pahang”

10
23. “15/06/2020”
24. 750
25. 0.1

26. 50.25

27. 502.50

28. 452.25

29.

11

You might also like