;; 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 lect07) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) #| calculate ebay fees: When you sell something on ebay, you are charged: - a listing fee, $0.30 - a gallery-plus fee, $0.35, *if* you used the gallery. - a final-value fee: 10% of up to the first $100; 5% of up to the next $900; 2% thereafter. [N.B. sometime in 2013, ebay changed this to just 10% of price+shipping.] Follow the design recipe: 4. write test cases 5 (a-d): header, purpose, contract/type, stub-return 7. complete the body 8. run tests [...10min of class work here...] How to do if-else-if? use `cond`. Pay close attention to the parens. Syntax: (cond [q1 a1] [q2 a2] ... [qn an]) where each q1,..,qn and a1,..,an are expressions, possibly w/ their own parens. Note that racket treats all types of parens the same, so long as they match: {define n 5} is entirely legal (if non-standard). |# (define FLAT-INSERT-FEE 0.30) (define GALLERY-FEE 0.35) (define REVOKE-PENALTY 5.00) #| Now, last 5min: - Modify the problem: the function can be given a sale-price, *or* the symbol 'unsold (no fees at all), or the symbol 'canceled ($5 plus insertion fee and gallery fee) - These inputs are *union* types: [0,100) u [100,1000) u [1000,+infty) {'unsold} u {'canceled} u real Design recipe update: 6a. If handling union data, use a *cond*, with one branch for each type. |#