EECS 111 Lecture Notes - Lecture 3: Radius

40 views4 pages

Document Summary

From now on, when we say worldstate, we mean integer. Render functions take world-states and return scenes. Always define constants (w/ uppercase) so that you can change them. Even if they"re not variable in your program. Ex: animation faceship (require 2htdp/image) (require 2htdp/universe: problem analysis, signature, purpose, header, examples, body, testing. ; - area of 20-by-35 is 700 (define (rectangle-area width height) (* width height)) (check-expect (rectangle-area 5 6) 30) (check-expect (rectangle-area 20 35) 700) ; - radius = 1 => area = . ; - radius = 3 => area = 9 (define (circle-area radius) (* (sqr radius) pi)) (check-within (circle-area 1) pi 0. 01) (check-within (circle-area 3) (* 9 pi) 0. 01) ; - volume when height and radius are both 1: . ; - volume when height is 10 and radius is 2: 40 (define (cylinder-volume radius height) (* (circle-area radius) height)) (check-within (cylinder-volume 1 1) pi 0. 01) (check-within (cylinder-volume 2 10) (* 40 pi) 0. 01)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents