Lab Scheme
Lab Scheme
Scheme is a language that using functional and basic data structure, List.
BUILT-IN FUNCTION
Mathematical function
LAB SCHEME
Predicates Function
LAB EXERCISES
2. Given the simple Scheme conversion function to bring Celsius degree amount into
Fahrenheit:
(define (fahrenheitConversion celcius)
(+ (* 1.8 celcius) 32))
a) What will be the output if current Celcius degree is 45?
b) Convert the given function to convert from Fahrenheit degree into Cel sius.
c) Based on your answer in (b), show how to call the function and its output if
Fahrenheit degree is 55.
4. A photo printing service charges less for each print when you order in bulk. For orders of
fewer than 10 prints, they charge RM 0.39 per print. For orders of more than 10 but fewer
than 50 prints, the cost per print is RM 0.29, and for orders of 50 or more prints, the price is
RM 0.24 per print. Write a function in Scheme that takes the number of prints ordered and
returns the total price.
5. By referring to the following table, write a scheme function that displays the respective
names of the speakers according to the type and selection chosen by the user.
Type Speaker
1 Don Bika
2 Eusof Islam
3 Dr Mahather
6. The National Earthquake Center has asked you to write a scheme f unction implementing the
f ollowing decision table to display characterization of an earthquake based on its Richter scale number.
ii) calBonus() that is able to receive the current salary and returns the amount of
bonus received based on the following table:
iii) calTotalIncome() that calls the functions in (i) and (ii) and sums the amount.