- ;; mht created on Nov 8, 2011
-
-
;; profit : number number -> number
-
;; to compute the profit as the difference between revenue and costs at some given ticket-price
-
;; example : (profit 5) should be (- 600 184.8)
-
(define (profit ticket-price)
-
(- (revenue ticket-price)
-
(costs ticket-price)))
-
-
;; revenue : number -> number
-
;; to compute the revenue given ticket-price
-
;; example : (revenue 5) should be (* 5 120)
-
(define (revenue ticket-price)
-
(* ticket-price
-
(attendees ticket-price)))
-
-
;; costs : number -> number
-
;; to compute the costs given ticket-price
-
;; example : (costs 5) should be (+ 180 (* 120 0.04))
-
(define (costs ticket-price)
-
(+ 180 (
-
* .04 (attendees ticket-price))))
-
-
;; attendees : number -> number
-
;; to compute the number of attendees, given ticket-price
-
;; example : (attendees 5) should be 120
-
;; (attendees 3) should be 420
-
;; (attendees 4) should be 270
-
(define (attendees ticket-price)
-
(+ 120
-
(* (/ 15 .10) (- 5.00 ticket-price))))
-
-
;; test:
-
(attendees 4)
-
(costs 5)
-
(profit 3)
-
(profit 4)
-
(profit 5)
-
-
;; new-costs: number -> number
-
;; to compute the costs given ticket-price
-
;;
-
(define (new-costs ticket-price)
-
(* 1.54 (attendees ticket-price)))
-
;; test
-
;(new-costs 5)
-
-
-
;; new-profit
-
(define (new-profit ticket-price)
-
(- (revenue ticket-price)
-
(new-costs ticket-price)))
-
-
(new-profit 3)
-
(new-profit 4)
- (new-profit 5)