0% found this document useful (0 votes)
519 views

CSC305 LabTestAB Questions

Uploaded by

xikigig993
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)
519 views

CSC305 LabTestAB Questions

Uploaded by

xikigig993
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/ 5

CONFIDENTIAL CS/LAB-TEST/MAY 2024/CSC305

UNIVERSITI TEKNOLOGI MARA

COURSE : PROGRAMMING PARADIGMS


COURSE CODE : CSC305
SESSION : MAY 2024
DURATION TO : 105 MINUTES
ANSWER
DURATION TO : 15 MINUTES
SUBMIT
CLO : CLO2 [MANIPULATE PROGRAMMING
PARADIGMS USING PROGRAMMING TOOLS.
(PLO3, P3)]

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:

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


This question paper consists of 9 printed pages
© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 2 CS/LAB-TEST/MAY 2024/CSC305

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:

Amount of purchase (RM) Points


Less than 500 100
More than or equal to 500 and less than 1000 300
More than or equal to 1000 500

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

a) Write functions in Scheme to calculate the points awarded to the customers.


b) Call functions defined in (a) to display the total points rewarded if the customer made
purchases of RM550 from preferred seller and successfully rated the product.
c) Call functions defined in (a) to display the total points rewarded if the customer made
purchases of RM1,200 from non-preferred seller and successfully rated the product.

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 3 CS/LAB-TEST/MAY 2024/CSC305

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.1: Electricity tariff charges for domestic users


Usage in a Month [kWh] Current Rate [cent/kWh]
For the first 200 kWh (1 - 200 kWh) per month 21.80
For the next 100 kWh (201 - 300 kWh) per month 33.40
For the next 300 kWh (301 - 600 kWh) per month 51.60
For the next 300 kWh (601 - 900 kWh) per month 54.60
For the next kWh (901 kWh onwards) per month 57.10

**The minimum monthly charge is RM3.00


Extracted from : https://www.tnb.com.my/residential/pricing-tariffs on 21 Apr 2024

Table 2.2 shows list of domestic users in Taman Bersatu, Nibong Tebal, Pulau Pinang and total
kWh electricity usage in Apr 2024.

Table 2.2: Domestic users in Taman Bersatu, Nibong Tebal


House No Owner Name kWh Category
1 Kamilah Ramli 184 B40
2 Sabri Yunus 483 T20
3 Markonah Timun 335 M40
4 Bakri Amin 783 T20
5 Lim Chee Hun 1044 T20
6 Gayathri Muthusamy 828 M40
7 Ng Swee Chin 288 B40
8 Mazlifah Mazni 0 T20
9 Mat Jasni Mat Jasri 2833 T20
10 Ku Ashikin Ku Chik 773 B40
11 Zarina Mydin 602 B40
12 Bah Bee Hun 582 T20

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.

Based on the information given above: -


a) Write complete facts for Table 2.2. (the functor name is ‘users’)

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).

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 5 CS/LAB-TEST/MAY 2024/CSC305

END OF QUESTION PAPER

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL

You might also like