Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #reader(lib "htdp-beginner-reader.ss" "lang")((modname 4.4.2) (read-case-sensitive #t) (teachpacks ((lib "convert.ss" "teachpack" "htdp"))) (htdp-settings #8(#t constructor repeating-decimal #f #t none #f ((lib "convert.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu (define BRACKET2 1000)
5 12687dd9 2023-08-04 jrmu (define BRACKET3 5000)
6 12687dd9 2023-08-04 jrmu (define BRACKETINT1 0.04)
7 12687dd9 2023-08-04 jrmu (define BRACKETINT2 0.045)
8 12687dd9 2023-08-04 jrmu (define BRACKETINT3 0.05)
9 12687dd9 2023-08-04 jrmu
10 12687dd9 2023-08-04 jrmu ;; interest-rate : number -> number
11 12687dd9 2023-08-04 jrmu ;; Given amount, it computes the interest rate
12 12687dd9 2023-08-04 jrmu ;; Divides the amount into brackets by using BRACKET2 and BRACKET3
13 12687dd9 2023-08-04 jrmu ;; Gives the interest rate based on where the value falls between the two brackets
14 12687dd9 2023-08-04 jrmu ;; BRACKETINT1, BRACKETINT2, BRACKETINT3 (bracket interest - the interest rate for
15 12687dd9 2023-08-04 jrmu ;; a given bracket)
16 12687dd9 2023-08-04 jrmu
17 12687dd9 2023-08-04 jrmu (define (interest-rate amount)
18 12687dd9 2023-08-04 jrmu (cond
19 12687dd9 2023-08-04 jrmu [(<= amount BRACKET2) BRACKETINT1]
20 12687dd9 2023-08-04 jrmu [(<= amount BRACKET3) BRACKETINT2]
21 12687dd9 2023-08-04 jrmu [(> amount BRACKET3) BRACKETINT3]))
22 12687dd9 2023-08-04 jrmu
23 12687dd9 2023-08-04 jrmu ;; interest : number -> number
24 12687dd9 2023-08-04 jrmu ;; Given the amount, calculates the total interest by multiplying the amount
25 12687dd9 2023-08-04 jrmu ;; by the interest-rate
26 12687dd9 2023-08-04 jrmu
27 12687dd9 2023-08-04 jrmu (define (interest amount)
28 12687dd9 2023-08-04 jrmu (* amount (interest-rate amount)))