;; The first three lines of this file were inserted by DrScheme. 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 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")))))
(define BRACKET2 240)
(define BRACKET3 480)
(define BRACKETRATE1 0.00)
(define BRACKETRATE2 0.15)
(define BRACKETRATE3 0.28)
;; tax-rate : number -> number
;; Given amount, it computes the tax rate
;; Divides the amount into brackets by using BRACKET2 and BRACKET3
;; Gives the tax rate based on where the value falls between the two brackets
;; BRACKETRATE1, BRACKETRATE2, BRACKETRATE3 (bracket rate - the tax rate for
;; a given bracket)
(define (tax-rate amount)
(cond
[(<= amount BRACKET2) BRACKETRATE1]
[(<= amount BRACKET3) BRACKETRATE2]
[(> amount BRACKET3) BRACKETRATE3]))
;; tax : number -> number
;; Given the amount, calculates the total tax by multiplying the amount
;; by the tax-rate
(define (tax amount)
(* amount (tax-rate amount)))