Blob


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.3) (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 (define BRACKET2 240)
5 (define BRACKET3 480)
6 (define BRACKETRATE1 0.00)
7 (define BRACKETRATE2 0.15)
8 (define BRACKETRATE3 0.28)
10 ;; tax-rate : number -> number
11 ;; Given amount, it computes the tax rate
12 ;; Divides the amount into brackets by using BRACKET2 and BRACKET3
13 ;; Gives the tax rate based on where the value falls between the two brackets
14 ;; BRACKETRATE1, BRACKETRATE2, BRACKETRATE3 (bracket rate - the tax rate for
15 ;; a given bracket)
17 (define (tax-rate amount)
18 (cond
19 [(<= amount BRACKET2) BRACKETRATE1]
20 [(<= amount BRACKET3) BRACKETRATE2]
21 [(> amount BRACKET3) BRACKETRATE3]))
23 ;; tax : number -> number
24 ;; Given the amount, calculates the total tax by multiplying the amount
25 ;; by the tax-rate
27 (define (tax amount)
28 (* amount (tax-rate amount)))