;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; PROBLEM ;; Design a function that converts Celsius degrees into Fahrenheit. ;; Celsius is a Number ;; Fahren is a Number ;; cel->fah: Number -> Number ;; Converts celsius temp to fahrenheit temp ;; Domain knowledge: fah = (cel * 9/5) + 32 (define (cel->fah c) (+ 32 (* 9/5 c))) ;; given: 0 | 100 | -40 ... ;; wanted: 32 | 212 | -40 ... (check-expect (cel->fah 0) 32) (check-expect (cel->fah 100) 212) (check-expect (cel->fah -40) -40) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; PROBLEM ;; Design a function that takes the last name of a Fundies 1 prof ;; and produces their section number ;; Shivers teaches 01 ;; Razzaq teaches 02 ;; Lerner teaches 03 ;; Ahmed teaches 05 ;; An F1prof is one of: ;; - "Shivers" ;; - "Razzaq" ;; - "Lerner" ;; - "Ahmed" ;; interp: names of Fundamentals 1 profs ;; Template #;(define (f1prof-temp prof) (cond [(string=? prof "Shivers") ...] [(string=? prof "Razzaq") ...] [(string=? prof "Lerner") ...] [(string=? prof "Ahmed") ...])) ;; A Section is one of: ;; - "01" ;; - "02" ;; - "03" ;; - "05" ;; get-section : F1prof -> Section ;; retrieves the section number of the class taught by prof (define (get-section prof) (cond [(string=? prof "Shivers") "01"] [(string=? prof "Razzaq") "02"] [(string=? prof "Lerner") "03"] [(string=? prof "Ahmed") "05"])) ;; Examples: ;; "Shivers" -> "01" ;; "Razzaq" -> "02" ;; "Lerner" -> "03" ;; "Ahmed" -> "05" (check-expect (get-section "Shivers") "01") (check-expect (get-section "Razzaq") "02") (check-expect (get-section "Lerner") "03") (check-expect (get-section "Ahmed") "05") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #| --------------------------------------------------------------- PROBLEM: Design an airline customer system. The system represents each customer via a title, first name, and last name. Airlines use the following titles: Dr., Mr., Ms. The system should also support a function for writing formal letter openers and a function for measuring the number of characters in a customer record. Problem 1: Create a data definition for customer records. Problem 2: Design a function that produces a letter formal opening from a customer record. Remember that a formal letter opening is something such as "Dear Dr. Racket:". Problem 3: Design a function that counts the characters in a customer record. |# (define-struct cust (title first last)) ;; A Customer is a (make-cust Title String String) ;; ;; A Title is one of: ;; - "Dr." ;; - "Mr." ;; - "Ms." ;; cust-temp : Customer -> ? #;(define (cust-temp c) ... (cust-title c) ... (cust-first c) ... (cust-last c) ...) ;; opening: Customer -> String ;; produces a formal letter opening, e.g., "Dear Dr. Shivers:" (define (opening c) (string-append "Dear " (cust-title c) " " (cust-last c) ":")) ;; Examples of Customer: (define c1 (make-cust "Dr." "Matthias" "Shivers")) (define c2 (make-cust "Mr." "Olin" "Shivers")) (define c3 (make-cust "Ms." "Leena" "Razzaq")) ;; Examples/Tests (check-expect (opening c1) "Dear Dr. Shivers:") (check-expect (opening c2) "Dear Mr. Shivers:") (check-expect (opening c3) "Dear Ms. Razzaq:") ;; Left to *you* as an exercise: ;; Problem 3: Design a function that counts the characters in a ;; customer record. E.g., number of characters in c1 is 18