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