;; 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 11.2.1) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor mixed-fraction #f #t none #f ())))
; Worked exercise 11.2.1

(define PRICE-PER-GALLON 2.459)

; gas-cost : number(miles) -> number

; Note: all the test cases will need to be modified if PRICE-PER-GALLON changes.
(check-within (gas-cost 0) 0 .01)
(check-within (gas-cost 28) 2.459 .01) ; i.e.   one gallon
(check-within (gas-cost 56) 4.918 .01) ; i.e.   two gallons
(check-within (gas-cost 77) 6.76 .01)  ; 2-3/4 gal; use calculator
(check-within (gas-cost 358) 31.44 .01) ; yecch; use calculator

(define (gas-cost miles)
  ; miles           a number
  ; #i28            a fixed number (mpg)
  ; 2.459           a fixed number ($/gal)
  (* PRICE-PER-GALLON (/ miles #i28))
  )

