Blame


1 12687dd9 2023-08-04 jrmu (define BRACKET2 1000)
2 12687dd9 2023-08-04 jrmu (define BRACKET3 5000)
3 12687dd9 2023-08-04 jrmu (define BRACKETINT1 0.04)
4 12687dd9 2023-08-04 jrmu (define BRACKETINT2 0.045)
5 12687dd9 2023-08-04 jrmu (define BRACKETINT3 0.05)
6 12687dd9 2023-08-04 jrmu
7 12687dd9 2023-08-04 jrmu ;; interest-rate : number -> number
8 12687dd9 2023-08-04 jrmu ;; Given amount, it computes the interest rate
9 12687dd9 2023-08-04 jrmu ;; Divides the amount into brackets by using BRACKET2 and BRACKET3
10 12687dd9 2023-08-04 jrmu ;; Gives the interest rate based on where the value falls between the two brackets
11 12687dd9 2023-08-04 jrmu ;; BRACKETINT1, BRACKETINT2, BRACKETINT3 (bracket interest - the interest rate for
12 12687dd9 2023-08-04 jrmu ;; a given bracket)
13 12687dd9 2023-08-04 jrmu
14 12687dd9 2023-08-04 jrmu (define (interest-rate amount)
15 12687dd9 2023-08-04 jrmu (cond
16 12687dd9 2023-08-04 jrmu [(<= amount BRACKET2) BRACKETINT1]
17 12687dd9 2023-08-04 jrmu [(<= amount BRACKET3) BRACKETINT2]
18 12687dd9 2023-08-04 jrmu [(> amount BRACKET3) BRACKETINT3]))
19 12687dd9 2023-08-04 jrmu
20 12687dd9 2023-08-04 jrmu ;; interest : number -> number
21 12687dd9 2023-08-04 jrmu ;; Given the amount, calculates the total interest by multiplying the amount
22 12687dd9 2023-08-04 jrmu ;; by the interest-rate
23 12687dd9 2023-08-04 jrmu
24 12687dd9 2023-08-04 jrmu (define (interest amount)
25 12687dd9 2023-08-04 jrmu (* amount (interest-rate amount)))