|
Comp210: Principles of Computing and Programming
Fall 2004 -- Homework
#1
|
Before you start the homework, you should remind yourself of our General
Advice,
Advice on Homeworks, and Grading Guidelines. All are available from the
class web
site (
http://www.owlnet.rice.edu/~comp210) .
- You should turn in one copy of the
homework for your team (not one per person) .
- Clearly print the names of all team members on the paper work.
- Staple together all of the pages (before you get to class).
- Upload the DrScheme file to the homework upload site.
- Be sure that all team member names are inside the DrScheme
file!
Read Sections 1 through 4 of the How To Design Programs book (go to
the on-line
version of book if unavailable).
- ( 5point) Put the following expressions into Scheme s prefix notation.
Type the
results into Dr. Scheme s definitions window (try it in the interactions
window first), execute it and see if you get the expected results.
- 17
- 17 * 12
- 170 * 5 * 12
- 5 * 6 * 7 * 8
- ( 20 points) Hand evaluate the following Scheme expressions on a
sheet of paper. After you are done,
type them into the definitions window in Dr. Scheme to confirm your
results.
- (- (* 3 5) 20)
- (* pi (* 10 10))
- (+ 73 false)
- (/ 12 0)
- ( 15 points) Go to the definitions window and type in the
three
functions from Lecture 1:
owes,
dough-area, and
pizza-topping-area. Click the execute button. Go to the
interactions window, and invoke each function on two different arguments.
Hand in your code and your tests.
- ( 10 points) Write a function
Rectangle-area
that consumes a height and a width, and
produces the area of a rectangle of that size. Be sure to write down the
contract and
purpose. Test your program on several inputs. Hand evaluate the expression
(Rectangle-area 10 15)
on paper.
(Here is a sample hand
evaluation, to give you an idea of what we want.)
Hand in your work on paper in class on the
specified due date.
50 points total
Last Revised
Sunday, 21-Nov-2004 14:10:08 CST
©2004 Stephen Wong and Dung Nguyen