-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-2-3.rkt
69 lines (53 loc) · 1.6 KB
/
1-2-3.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
;; 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 1-2-3) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
(define (letter fst lst signature-name)
(string-append
(opening fst)
"\n\n"
(body fst lst)
"\n\n"
(closing signature-name)))
(define (opening fst)
(string-append "Dear " fst ","))
(define (body fst lst)
(string-append
"We have discovered that all people with the" "\n"
"last name " lst " have won our lottery. So, " "\n"
fst ", " "hurry and pick up your prize."))
(define (closing signature-name)
(string-append
"Sincerely,"
"\n\n"
signature-name
"\n"))
(require 2htdp/batch-io)
(define SENSITIVITY 15)
(define (attendees ticket-price)
(- 120 (* (- ticket-price 5.0) (/ SENSITIVITY 0.1))))
(define (revenue ticket-price)
(* ticket-price (attendees ticket-price)))
;(define fixedcost 180)
;(define costperattendee .04)
(define fixedcost 0)
(define costperattendee 1.50)
(define (cost ticket-price)
(+ fixedcost (* costperattendee (attendees ticket-price))))
(define (profit ticket-price)
(- (revenue ticket-price)
(cost ticket-price)))
(define (profitv2 price)
(- (* (+ 120
(* (/ 15 0.1)
(- 5.0 price)))
price)
(+ 180
(* 0.04
(+ 120
(* (/ 15 0.1)
(- 5.0 price)))))))
(profit 1)
(profit 2)
(profit 3)
(profit 4)
(profit 5)