1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #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")))))
6 (define BRACKETINT1 0.04)
7 (define BRACKETINT2 0.045)
8 (define BRACKETINT3 0.05)
10 ;; interest-rate : number -> number
11 ;; Given amount, it computes the interest rate
12 ;; Divides the amount into brackets by using BRACKET2 and BRACKET3
13 ;; Gives the interest rate based on where the value falls between the two brackets
14 ;; BRACKETINT1, BRACKETINT2, BRACKETINT3 (bracket interest - the interest rate for
17 (define (interest-rate amount)
19 [(<= amount BRACKET2) BRACKETINT1]
20 [(<= amount BRACKET3) BRACKETINT2]
21 [(> amount BRACKET3) BRACKETINT3]))
23 ;; interest : number -> number
24 ;; Given the amount, calculates the total interest by multiplying the amount
25 ;; by the interest-rate
27 (define (interest amount)
28 (* amount (interest-rate amount)))