The Old Farmer's Almanac (almanac.com) describes how farmers accurately determine the temperature from a cricket's chirps:
To convert cricket chirps to degrees Fahrenheit, count number of chirps in 14 seconds then add 40 to get temperature.Your boss, Dr. Fahma, has the brilliant idea of producing a chirp-o-meter. This hand-held instrument allows farmers to type in the number of cricket chirps in 14 seconds and it then shows the current temperature. Your job is to develop the software for the chirp-o-meter.
Design the function chirp-o-temp, which consumes the number of chirps per 14 seconds and produces the current temperature (Fahrenheit).
Solution:
;; Grader: Theo ;; chirp-o-temp: Number -> Number [1pt] ;; compute temperature from given chirps/14 seconds [1pt] ;; example: given 20, the temperature is 60. [1pt] (define (chirp-o-temp chirps) ;; [2pts for correct definition] (+ chirps 40)) ;; Tests: [1pt, 2 if there is no example] (equal? (chirp-o-temp 20) 60)