Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-beginner-reader.ss" "lang")((modname 3.3.2-3.3.4) (read-case-sensitive #t) (teachpacks ((lib "convert.ss" "teachpack" "htdp"))) (htdp-settings #8(#t constructor repeating-decimal #f #t none #f ((lib "convert.ss" "teachpack" "htdp")))))
4 (define PI 3.14)
6 ;; area-of-circle : number -> number
7 ;; Computes the area of the circle given the radius
9 (define (area-of-circle radius)
10 (* PI (sqr radius)))
12 ;; area-of-ring : number number -> number
13 ;; Computes the area of a ring given the inner and outer radii.
14 ;; It does so by subtracting the area of the inner circle from the outer circle.
16 (define (area-of-ring inner outer)
17 (- (area-of-circle outer) (area-of-circle inner)))
19 ;; volume-cylinder : number number -> number
20 ;; Computes the volume of a cylinder given the radius and height.
21 ;; It does so by multiplying the area of the base by the height.
23 (define (volume-cylinder radius height)
24 (* (area-of-circle radius) height))
26 ;; lateral-surface-area : number number -> number
27 ;; Computes the lateral surface area of a cylinder given the radius and height (the circumference times the height)
29 (define (lateral-surface-area radius height)
30 (* 2 PI radius height))
32 ;; area-cylinder : number number -> number
33 ;; Computes the surface area of a cylinder given the radius and height
34 ;; It does so by adding 2 times the area of the base by the lateral surface area.
36 (define (area-cylinder radius height)
37 (+
38 (* 2 (area-of-circle radius))
39 (lateral-surface-area radius height)))
41 ;; area-pipe : number number number -> number
42 ;; Computes the surface area of a pipe given its inner radii, thickness, and height.
43 ;; It does so by finding the lateral surface area of the outer shell and the inner shell and adding this to two times the surface area of either the top or bottom ring.
45 (define (area-pipe inner thick height)
46 (+
47 (lateral-surface-area (+ inner thick) height)
48 (lateral-surface-area inner height)
49 (* 2 (area-of-ring inner (+ inner thick)))))
51 ;; area-pipe2 : number number number -> number
52 ;; Computes the surface area of a pipe according the the following formula
53 ;; A = 2*PI*(inner+thick)*height)+(2*PI*inner*height)+2*PI*((inner+thick)^2-inner^2)
55 (define (area-pipe2 inner thick height)
56 (+
57 (* 2 PI (+ inner thick) height)
58 (* 2 PI inner height)
59 (* 2 PI
60 (- (sqr (+ inner thick)) (sqr inner)))))