Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer all Functional and Logic programming questions below. 1. Given the following cylinder diagram: h Write a Scheme program segment to compute: i) The surface

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Answer all Functional and Logic programming questions below. 1. Given the following cylinder diagram: h Write a Scheme program segment to compute: i) The surface area of the cylinder diagram; Surface area = 2nrh + 2nr 2 ii) The volume of the cylinder diagram; Volume = nr2h 2. Predict the output when the following statements in Scheme are executed: a. 2xy + 3y2 b. x+y2 2x+3y C. 2x2 - 4xy + 2y2 (6 marks) 3. The following a a formula to calculate Body Mass Index (BMI). weight(kg) BMI = height(m) * height(m) If your BMI is under 20, you might be underweight. Between 20 and 25, you are probably at a good healthy weight for your height. A BMI over 25 is considered overweight, and over 35 is considered obese. Write an expression in Scheme to determine BMI of a person. (5 marks) 4. Write a function in Scheme to calculate the total charge should be paid by visitors at The Carnival Waterpark Sungai Petani. The rate for categories and activities are based on the following Table 1. (5 marks) Table 1 Category Activities Fees (RM) Entrance Fees (RM) 35 Adult (1) Child (2) Beautiful Beach Surf (1) Water Coaster Rides (2) Beautiful Beach Surf (1) Water Coaster Rides (2) 25 20 20 15 20 5. Given the following code in C language, rewrite the code in Scheme. (5 marks) int funt 4 (int n) { if (n == 1) return 1; else return n + funct4(n-1); 7. Prolog is one of the languages used in Logic Programming Paradigms a. Explain about Prolog. (2 marks) b. Give THREE (3) sectors where Prolog is used. (3 marks) 8. Given the following knowledge base in Prolog statements. touring_bike (puteri). mountain bike (putera). state_player (putera). bmx (putera). touring_bike (X) :- hassleepingBag (X), hasWaterBottle (X). hasWater Bottle (X) :- state_player (X). i) List the facts from the knowledge base above. (2 marks) ii) List the rules from the knowledge base above. (1 mark) How does Prolog statements respond to the following queries? (2 marks) a) ?-touring_bike (puteri). b) ?- hasWaterBottle (X). c) ?-touring_bike (putera). d) ?-state_player (X). iv) Create the rules to show a state player should has BMX and Mountain Bike. (1 mark) 9. Given the following graph of possible path from Gurun and Tanjung Dawai to UiTM Kedah. Bedong Semeling UiTM Kedah Gurun WIR Tanjung Dawai Sg. Lalang Laguna Merbok Singkir i) Write the facts to show all possible path between 2 places. (4.5 marks) ii) Based on facts in (i), write the rules to show the possible path from Gurun to UiTM Kedah. (4.5 marks) iii) Write another facts to show all possible path from Gurun to UiTM Kedah and from Tanjung Dawai to UiTM Kedah. (3 marks) 10. Consider the following statements: pizza is food lasagna is food Mikayla eats lasagna a. Write the facts based on the above statements. (3 marks) b. Create rules for Mikayla likes every food she eats. (2 marks) c. Write the goal/result for each query. i. ji. likes (mikayla, Y) likes (lisa,x). (2 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

Thank the customer politely, using his or her name.

Answered: 1 week ago

Question

3. The group answers the questions.

Answered: 1 week ago

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago