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.14|) (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 ;; profit : number -> number
5 12687dd9 2023-08-04 jrmu ;; Calculates profit as a difference between profit and revenue depending on the ticket-price
6 12687dd9 2023-08-04 jrmu ;; Example: (profit 5) should give 415.2, (profit 4) should give 889.2, (profit 3) should give 1063.2
7 12687dd9 2023-08-04 jrmu
8 12687dd9 2023-08-04 jrmu (define (profit ticket-price)
9 12687dd9 2023-08-04 jrmu (- (revenue ticket-price) (costs ticket-price)))
10 12687dd9 2023-08-04 jrmu
11 12687dd9 2023-08-04 jrmu ;; revenue : number -> number
12 12687dd9 2023-08-04 jrmu ;; Calculates revenue, which is given as the ticket-price times the number of attendees.
13 12687dd9 2023-08-04 jrmu ;; Example: (revenue 5) should give 600, (revenue 4) should give 1080, and (revenue 3) should give 1260
14 12687dd9 2023-08-04 jrmu (define (revenue ticket-price)
15 12687dd9 2023-08-04 jrmu (* ticket-price (attendees ticket-price)))
16 12687dd9 2023-08-04 jrmu
17 12687dd9 2023-08-04 jrmu ;; costs : number -> number
18 12687dd9 2023-08-04 jrmu ;; Calculates costs, which has a fixed cost plus a variable cost that depends on the ticket-price
19 12687dd9 2023-08-04 jrmu ;; Example: (costs 5) should give 184.8, (costs 4) should give 190.8, and (costs 3) should give 196.8
20 12687dd9 2023-08-04 jrmu
21 12687dd9 2023-08-04 jrmu (define (costs ticket-price)
22 12687dd9 2023-08-04 jrmu (+ 180 (* 0.04 (attendees ticket-price))))
23 12687dd9 2023-08-04 jrmu
24 12687dd9 2023-08-04 jrmu ;; attendees : number -> number
25 12687dd9 2023-08-04 jrmu ;; Calculates the number of attendees as a function of the ticket price
26 12687dd9 2023-08-04 jrmu ;; Example: (attendees 5) should give 120
27 12687dd9 2023-08-04 jrmu ;; Example: (attendees 4) should give 270
28 12687dd9 2023-08-04 jrmu ;; Example: (attendees 3) should give 420
29 12687dd9 2023-08-04 jrmu
30 12687dd9 2023-08-04 jrmu (define (attendees ticket-price)
31 12687dd9 2023-08-04 jrmu (+ 120 (* (/ (- 5 ticket-price) 0.1) 15)))