Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #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 12687dd9 2023-08-04 jrmu (define PI 3.14)
5 12687dd9 2023-08-04 jrmu
6 12687dd9 2023-08-04 jrmu ;; area-of-circle : number -> number
7 12687dd9 2023-08-04 jrmu ;; Computes the area of the circle given the radius
8 12687dd9 2023-08-04 jrmu
9 12687dd9 2023-08-04 jrmu (define (area-of-circle radius)
10 12687dd9 2023-08-04 jrmu (* PI (sqr radius)))
11 12687dd9 2023-08-04 jrmu
12 12687dd9 2023-08-04 jrmu ;; area-of-ring : number number -> number
13 12687dd9 2023-08-04 jrmu ;; Computes the area of a ring given the inner and outer radii.
14 12687dd9 2023-08-04 jrmu ;; It does so by subtracting the area of the inner circle from the outer circle.
15 12687dd9 2023-08-04 jrmu
16 12687dd9 2023-08-04 jrmu (define (area-of-ring inner outer)
17 12687dd9 2023-08-04 jrmu (- (area-of-circle outer) (area-of-circle inner)))
18 12687dd9 2023-08-04 jrmu
19 12687dd9 2023-08-04 jrmu ;; volume-cylinder : number number -> number
20 12687dd9 2023-08-04 jrmu ;; Computes the volume of a cylinder given the radius and height.
21 12687dd9 2023-08-04 jrmu ;; It does so by multiplying the area of the base by the height.
22 12687dd9 2023-08-04 jrmu
23 12687dd9 2023-08-04 jrmu (define (volume-cylinder radius height)
24 12687dd9 2023-08-04 jrmu (* (area-of-circle radius) height))
25 12687dd9 2023-08-04 jrmu
26 12687dd9 2023-08-04 jrmu ;; lateral-surface-area : number number -> number
27 12687dd9 2023-08-04 jrmu ;; Computes the lateral surface area of a cylinder given the radius and height (the circumference times the height)
28 12687dd9 2023-08-04 jrmu
29 12687dd9 2023-08-04 jrmu (define (lateral-surface-area radius height)
30 12687dd9 2023-08-04 jrmu (* 2 PI radius height))
31 12687dd9 2023-08-04 jrmu
32 12687dd9 2023-08-04 jrmu ;; area-cylinder : number number -> number
33 12687dd9 2023-08-04 jrmu ;; Computes the surface area of a cylinder given the radius and height
34 12687dd9 2023-08-04 jrmu ;; It does so by adding 2 times the area of the base by the lateral surface area.
35 12687dd9 2023-08-04 jrmu
36 12687dd9 2023-08-04 jrmu (define (area-cylinder radius height)
37 12687dd9 2023-08-04 jrmu (+
38 12687dd9 2023-08-04 jrmu (* 2 (area-of-circle radius))
39 12687dd9 2023-08-04 jrmu (lateral-surface-area radius height)))
40 12687dd9 2023-08-04 jrmu
41 12687dd9 2023-08-04 jrmu ;; area-pipe : number number number -> number
42 12687dd9 2023-08-04 jrmu ;; Computes the surface area of a pipe given its inner radii, thickness, and height.
43 12687dd9 2023-08-04 jrmu ;; 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.
44 12687dd9 2023-08-04 jrmu
45 12687dd9 2023-08-04 jrmu (define (area-pipe inner thick height)
46 12687dd9 2023-08-04 jrmu (+
47 12687dd9 2023-08-04 jrmu (lateral-surface-area (+ inner thick) height)
48 12687dd9 2023-08-04 jrmu (lateral-surface-area inner height)
49 12687dd9 2023-08-04 jrmu (* 2 (area-of-ring inner (+ inner thick)))))
50 12687dd9 2023-08-04 jrmu
51 12687dd9 2023-08-04 jrmu ;; area-pipe2 : number number number -> number
52 12687dd9 2023-08-04 jrmu ;; Computes the surface area of a pipe according the the following formula
53 12687dd9 2023-08-04 jrmu ;; A = 2*PI*(inner+thick)*height)+(2*PI*inner*height)+2*PI*((inner+thick)^2-inner^2)
54 12687dd9 2023-08-04 jrmu
55 12687dd9 2023-08-04 jrmu (define (area-pipe2 inner thick height)
56 12687dd9 2023-08-04 jrmu (+
57 12687dd9 2023-08-04 jrmu (* 2 PI (+ inner thick) height)
58 12687dd9 2023-08-04 jrmu (* 2 PI inner height)
59 12687dd9 2023-08-04 jrmu (* 2 PI
60 12687dd9 2023-08-04 jrmu (- (sqr (+ inner thick)) (sqr inner)))))