Com1100 Exam 1 - Fall 2002 

 

Name:
Student Id (last 4 digits) :

Write down the answers in the space provided. Do not attach any extra sheets. Use what you know from the lectures, labs, and the assigned readings from the books. Do not use any extra knowledge about The Beginning Student Language.

The phrase ``develop a program'' means to design a program according to one of the recipes. You are not required to provide a template unless the problem specifically asks for one. However, be prepared to struggle with the development of function bodies if you choose to skip the template step.

0.1  Exercise

Grader: V. Proulx

Points: 2pt

Write a purpose and contract for a function that computes the number of calories per serving for snack chips. It consumes the number of servings and calories for a bag.


;; calories : Number Number  -->  Number
;; to compute the total calories consumed,
;; given number-of-servings and calories-per-serving
(define (calories number-of-servings calories-per-serving) ...)


0.2  Exercise

Grader: V. Proulx

Points: 3pt

Write the purpose, contract, and two examples for a function that computes the surface area of a cube given the length of a side.


;; surface : Number  -->  Number
;; to compute the surface area of a cube

(= (surface 1) 6)
(= (surface 2) 24)


Last modified: Wed, Oct 23, 2002, 2:16 pm
HTML conversion by TeX2page 4p4k5