You will find below a payroll program that calculates gross pay (adding overtime when applicable), federal income tax, and union dues. Rewrite the program so it also calculates and withholds state income and health insurance. You will find the manner in which these are calculated below.
State Tax is:
Gross pay | State Tax Rate |
---|---|
Gross < 80 | 0.5% |
Gross < 150 | 1% |
Gross < 250 | 2% |
Gross < 500 | 3% |
Gross < 800 | 5% |
Health insurance is:
The Program:
;; gross-pay : number number --> number ;; gross-pay calculates the gross, which is zero if either input ;; is negative and adds time-and-a-half for hours over 40 (define (gross-pay rate hours) (cond [(< hours 0) 0] [(< rate 0) 0] [(<= hours 40) (* rate hours)] [else (+ (*rate 40) (* (* 1.5 rate) (- hours 40) ))] ) ) ;; fed-tax : number --> number ;; Calculates federal income tax where there is no tax when ;; gross < 100 and the rates are: ;; 10% where 100 <= gross < 300 ;; 15% where 300 <= gross < 500 ;; 17% where 500 <= gross < 800 ;; 20% where 110 <= gross (define (fed-tax gross) (cond [(< gross 100) 0] [(< gross 300) (* 0.10 gross)] [(< gross 500) (* 0.15 gross)] [(< gross 800) (* 0.17 gross)] [(< gross 1100) (* 0.20 gross)] ) ) ;; 15% where 300 <= gross < 500 ;; union-dues: symbol --> number ;; dues are 15 for singles employees and 10 for married employees (define (union-dues marital-status) (cond [(eq? marital-status 'single) 15] [(eq? marital-status 'married) 10] ) ) ;; net-pay : number number symbol --> number ;; Deducts federal tax and union dues from gross pay (define (net-pay rate hours marital-status) (- (- (gross-pay rate hours) (fed-tax (gross-pay rate hours))) (union-dues marital-status)) )