Exercise 4.4.3: (back)

;; pay-back : number -> number
;; Examples: (pay-back 400) => 1
;; Examples: (pay-back 1400) => 5.75
;; Examples: (pay-back 2000) => 10
;; Examples: (pay-back 2600) => 14.75
(define (pay-back amount)
  (cond
    [(<= amount 500) (pay-back-charge amount 0.25)]
    [(<= amount 1500) (+ (pay-back 500) (pay-back-charge (- amount 500) 0.50))]
    [(<= amount 2500) (+ (pay-back 1500) (pay-back-charge (- amount 1500) 0.75))]
    [(> amount 2500) (+ (pay-back 2500) (pay-back-charge (- amount 2500) 1.0))]))


;; pay-back-charge : number -> number
(define (pay-back-charge amount rate)
  (* rate (/ 1 100) amount))
  
  
;; Tests
> (= (pay-back 400) 1)
true

> (= (pay-back 1400) 5.75)
true

> (= (pay-back 2000) 10)
true

> (= (pay-back 2600) 14.75)
true