;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname movie_theater) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; Contract: number -> number ;; Purpose: computes the profit for a movie ;; theater given a ticket price ;; Example: if revenue is 600 and the cost is 200 ;; then the profit is 400 (define (profit ticket-price) (- (revenue ticket-price) (cost ticket-price))) ;; Contract: number -> number ;; Purpose: computes the revenue for a movie ;; theater given a ticket price ;; Example: if the number of attendees for $5 per ticket ;; is 120 then the revenue is 600. (define (revenue ticket-price) (* (attendees ticket-price) ticket-price)) ;; Contract: number -> number ;; Purpose: computes the cost for a movie ;; theater to run a movie given a ticket price ;; Examples: if there are 120 attendees then the cost is 184.8 ;; Examples: if there are 420 attendees then the cost is 196.8 (define (cost ticket-price) (+ 180 (* .04 (attendees ticket-price)))) ;; Contract: number -> number ;; Purpose: computes the number of movie attendees ;; given a ticket price ;; examples: ;; (attendees 5.00) returns 120 ;; (attendees 3.00) returns 420 (define (attendees ticket-price) (+ 120 (* (/ 15 .10) (- 5.00 ticket-price)))) ;; tests for attendees (attendees 5.00) ; expected result 120 ;; another way of testing: (check-expect (attendees 5.00) 120) (check-expect (attendees 3.00) 420) ;; tests for cost (check-expect (cost 5.00) 184.8) (check-expect (cost 3.00) 196.8) ;; tests for revenue: (check-expect (revenue 5.00) 600) (check-expect (revenue 3.00) 1260) ;; tests for profit (check-expect (profit 5.00) 415.2) (check-expect (profit 3.00) 1063.2) ;; Tasks: ;; exercise 3.1.4: change the program so that the cost is $1.50 ;; per attendee with no fixed cost (write this solution in a ;; separate file since all the tests will change as well ;; change the program so that there is a limit on the number of ;; attendees: the movie theater can seat at most 400 people.