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) .

 

 

Read Sections 1 through 4 of the How To Design Programs book (go to the on-line version of book if unavailable).

 

  1. ( 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.
    1. 17
    2. 17 * 12
    3. 170 * 5 * 12
    4. 5 * 6 * 7 * 8

  2. ( 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.
    1. (- (* 3 5) 20)
    2. (* pi (* 10 10))
    3. (+ 73 false)
    4. (/ 12 0)

  3. ( 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.

  4. ( 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