CSC305 LabTestAB Questions
CSC305 LabTestAB Questions
INSTRUCTIONS TO CANDIDATES
1. Answer ALL questions. The students must use the appropriate software editor and
compiler to answer the questions.
2. For each question, copy the codes or expressions from the editor as your answer and
paste accordingly in this question paper. Submit the softcopy of this question paper in PDF
format with the complete answer for each question through Google Form specified.
UiTM No.:
Name:
Group:
Lecturer’s Name:
Date:
QUESTION 1
Jungle Bee Sdn Bhd offers point rewards to customers based on their purchases. Based on
the purchases made, it offers points to its customers as shown in the table given below:
Additional points are also rewarded to the customers if they rated the product as well as
made purchases from preferred sellers as shown in the table below:
Conditions
Successfully rated a Purchases made from Additional Points
product preferred sellers
No No 0
Yes No 50
No Yes 50
Yes Yes 100
QUESTION 2
You have been placed in the ICT department of Tenaga Nasional Berhad as new ICT Officer.
The first assignment has been given to you to calculate total charges of electricity usage. The
following Table 2.1 shows the details of electricity tariff charges for domestic users only.
Table 2.2 shows list of domestic users in Taman Bersatu, Nibong Tebal, Pulau Pinang and total
kWh electricity usage in Apr 2024.
TNB has announced that for all B40 categories, they will pay RM20 per month only, no matter
what although they have used more than normal. If the total charge is less than RM20, then
they should pay for the total kWh used only for that month.
b) Write complete rules for Table 2.1. (the functor name is ‘charges’)
© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 4 CS/LAB-TEST/MAY 2024/CSC305
c) Write complete additional rules to consider finalized charges if the user’s category is
considered to determine total charges that the user should pay. (the functor name is
‘finalcharges’)
d) Write a rule to determine the highest finalized charges. (the functor name is
‘highestcharges’)
e) Test your code based on the following test data and give the responses.
1 ?- charges(1,X).
2 ?- charges(5,X).
3 ?- charges(8,X).
4 ?- finalcharges(1,X).
5 ?- finalcharges(8,X).
6 ?- finalcharges(12,X).
7 ?- charges(12,X).
8 ?- highestcharges(No,Who,Charge).