;; The first three lines of this file were inserted by DrRacket. 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 repeating-decimal #f #t none #f ()))) ; Worked exercises 11.2.1 ; gas-cost : number (miles) -> number (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 I know I’ll need ; PRICE-PER-GALLON ditto (* (/ miles #i28) 2.459) )