;; ;; FILE: homework02.rkt ;; AUTHOR: YOUR NAME ;; DATE: YOUR DATE ;; COMMENT: Provides templates for your solutions, plus a few tests. ;; ;; MODIFIED: ;; CHANGE: ;; #lang racket (require rackunit) ; enables you to use rackunit tests ; ------------------- ; ----- [1] ----- ; ------------------- (define quiz-percentage (lambda (quiz1 quiz2 quiz3) 0)) ; replace the 0 with your code (check-= (quiz-percentage 40 20 30) 0.5 0.01) (check-= (quiz-percentage 60 50 40) 0.8333 0.0001) (check-= (quiz-percentage 60 60 60) 1.0 0.01) ; ------------------- ; ----- [2] ----- ; ------------------- (define disc (lambda (a b c) 0 )) ; replace the 0 with your code (check-equal? (disc 1 4 4) 0) (check-equal? (disc -3 8 -4) 16) (check-equal? (disc 2 1 3) -23) ; ------------------- ; ----- [3] ----- ; ------------------- (define ladder-height (lambda (ladder-length base-distance) 0 )) ; replace the 0 with your code (check-= (ladder-height 10 6) 8.0 0.00001) (check-= (ladder-height 13 5) 12.0 0.00001) (check-= (ladder-height 20 3.5) 19.691368667515217 0.00001) ; ------------------- ; ----- [4] ----- ; ------------------- (define candy-temperature (lambda (temp elevation) 0 )) ; replace the 0 with your code (check-= (candy-temperature 244 5280) 233.44 0.00001) (check-= (candy-temperature 302 977.69) 300.04462 0.00001) (check-= (candy-temperature 302 -1401) 304.802 0.00001) ; ------------------- ; ----- [5] ----- ; ------------------- (define in-range? (lambda (actual desired epsilon) #f )) ; replace the #f with your code (check-equal? (in-range? 4.95 5.0 0.1) #t) (check-equal? (in-range? 4.95 5.0 0.01) #f) ;; not anymore! (check-equal? (in-range? 5.0 4.95 0.1) #t) ;; works both ways (check-equal? (in-range? 5.0 5.95 0.1) #f) (check-equal? (in-range? 5.5 5.95 0.5) #t) ; ----- end -----