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.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 12687dd9 2023-08-04 jrmu (define BRACKET2 240)
5 12687dd9 2023-08-04 jrmu (define BRACKET3 480)
6 12687dd9 2023-08-04 jrmu (define BRACKETRATE1 0.00)
7 12687dd9 2023-08-04 jrmu (define BRACKETRATE2 0.15)
8 12687dd9 2023-08-04 jrmu (define BRACKETRATE3 0.28)
9 12687dd9 2023-08-04 jrmu
10 12687dd9 2023-08-04 jrmu ;; tax-rate : number -> number
11 12687dd9 2023-08-04 jrmu ;; Given amount, it computes the tax 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 tax rate based on where the value falls between the two brackets
14 12687dd9 2023-08-04 jrmu ;; BRACKETRATE1, BRACKETRATE2, BRACKETRATE3 (bracket rate - the tax rate for
15 12687dd9 2023-08-04 jrmu ;; a given bracket)
16 12687dd9 2023-08-04 jrmu
17 12687dd9 2023-08-04 jrmu (define (tax-rate amount)
18 12687dd9 2023-08-04 jrmu (cond
19 12687dd9 2023-08-04 jrmu [(<= amount BRACKET2) BRACKETRATE1]
20 12687dd9 2023-08-04 jrmu [(<= amount BRACKET3) BRACKETRATE2]
21 12687dd9 2023-08-04 jrmu [(> amount BRACKET3) BRACKETRATE3]))
22 12687dd9 2023-08-04 jrmu
23 12687dd9 2023-08-04 jrmu ;; tax : number -> number
24 12687dd9 2023-08-04 jrmu ;; Given the amount, calculates the total tax by multiplying the amount
25 12687dd9 2023-08-04 jrmu ;; by the tax-rate
26 12687dd9 2023-08-04 jrmu
27 12687dd9 2023-08-04 jrmu (define (tax amount)
28 12687dd9 2023-08-04 jrmu (* amount (tax-rate amount)))