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