| PSICS Fall 2004 Quiz #1 |
|   PSICS Home   |   Question 1   |   Question 2 |
Submit your solutions to this quiz by emailing them to Eric (our TA) at meisne@cs.rpi.edu. You must send your email during the class period (we won't grade anything sent after the quiz is over). Please let us know if you have any problems sending your answers!
Every scheme function you write for this quiz should have documentation including:
| Question 1: Scheme feet to meter conversion functions | ( This question is worth 1/2 of this quiz grade ) |
Create a scheme function named feet->meter that
consumes a number (some number of feet) and produces the
corresponding number of meters. Here are some sample uses of
this function:
(feet->meter 1) ; should show 0.3048 (feet->meter 3280.8) ; should show almost 1000 (999.98784)
Create a scheme function named meter->feet that
converts from meters to feet and test it. More samples:
(meter->feet 1000) ; should be about 3280.73 feet (meter->feet (feet->meter 1.0) ) ; ?
Finally, create a scheme function named check that
consumes a number of feet, and produces a boolean (true or false). The
function check should produce true only if the conversion
of meter->feet of the result produced by
feet->meter is equal to the original number of feet.
Yell at Dave (ask for help) if it's not clear what is wanted here...
If both of your conversion function are correct, this should produce
true all the time (for exact numbers).
(check 1) ; should produce true (check 12.345) ; should produce true
NOTE: 1 foot = 0.3048 meter
| Question 2: Letter grade function | ( This question is worth 1/2 of this quiz grade ) |
Write a scheme function named assign_letter_grade that
consumes an integer and produces a symbol. The symbol represents the
letter grade corresponding to the integer course average. The function
should compute letter grades according to the (strange) formula
described below:
If the course average is above 90, the grade should be A
If the course average is above 80, but less than or equal to 90, the grade should be:
B+ if the average is an even number.
B- if the average is an odd number.
If the course average is 65 or above but less than or equal to 80, the course grade should be:
A if the average is divisible by 5
Otherwise the grade should be C
If the average is anything less than 65 the grade should be F
NOTES:
To create a symbol in scheme you put single
quote before the symbol, for example here is a scheme expression you
should use to represent a B+: 'B+.
You should assume that the course average is an integer
You can use the modulo scheme
function to produce the remainder of an integer division, for example
to find the remainder of 65 / 5: (modulo 65 5).