Exercise 3.1.4: (back)

;; How to design a program
;; Left Program Definition
(define (profit ticket-price)
  (- (revenue ticket-price)
     (cost ticket-price)))

(define (revenue ticket-price)
  (* (attendees ticket-price) ticket-price))

(define (cost ticket-price)
  (* 1.50 (attendees ticket-price)))

(define (attendees ticket-price)
  (+ 120
     (* (/ 15 .10) (- 5.00 ticket-price))))


> (profit 5.00)
420.0

> (profit 4.00)
675.0

> (profit 3.00)
630.0
;; How not to design a program
;; Right Program Definition
(define (profit price)
  (- (* (+ 120
	   (* (/ 15 .10)
	      (- 5.00 price)))
	price)
     (* 1.50
        (+ 120
           (* (/ 15 .10)
              (- 5.00 price))))))


> (profit 5.00)
420.0

> (profit 4.00)
675.0

> (profit 3.00)
630.0