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