Be sure to refer to the Laws of Homework when preparing your solutions.
A car-rental company bases its rates on three factors: the kind of car rented, the age of the renter, and a renter's membership in certain clubs that have arranged for discounts for their members. The company rents several types of cars; each type is specified according to the style (compact, mid-size, convertible, or mini-van), brand (Buick, GM, Ford), number of doors, and whether or not the car has a CD player.
Develop a data model for rental-car types. Include the define-struct needed to model your car types and three examples of car types created with your model.
State all of the operators (with their contracts) that are created from your define-struct in the previous question.
Develop a data model for rental-car reservations. A reservation contains the renter's last name, date the rental starts, date the rental ends, and the car type being reserved. Include the define-struct needed to model your reservations and three examples of reservations created with your model. You may choose/design your own data model for dates (but be sure to document it!).
Write a program base-rate
which consumes a car type
(according to your model) and returns the daily rental rate for a car
of that type. The rates are according to the following table:
compact | $21.99 |
mid-size | $27.99 |
convertible | $36.99 |
mini-van | $41.99 |
Write a program age-surcharge
which consumes a
renters age (at least 18) and returns a number representing the
daily surcharge for renters of that age. The surcharges are according
to the following table: [note: table edited 9/4 to fix second age range]
18-21 | $15 |
22-25 | $5 |
anything else | 0 |
Write a program discount
which consumes the name of a
discount program (a symbol) and returns a number representing the
percentage saved on a rental under the indicated program. The
returned percentages should follow the table below:
AAA or Allstate | 5% |
HOG (Harley Owners Group) | 7% |
none (or other) | 0% |
Write a program rental-rate
which takes a
car-type, the renter's age, and a rental discount code. This program
returns the daily car rental rate adjusted with the surcharges and
discounts. The discount applies to the base rate only, not to the age
surcharges.
Write a program change-res-car-type
, which consumes
a reservation and a car-type and returns a reservation with the same
name, start, and end dates as the original reservation, but with the
new car-type.
(sqrt (+ (* 3 3) (* 4 4))) ^^^^^^^ = (sqrt (+ 9 (* 4 4))) ^^^^^^^ = (sqrt (+ 9 16)) ^^^^^^^^ = (sqrt 25) ^^^^^^^^^ = 5
(/ (+ (square a) (square b)) 2) where square is defined as (define (square n) (* n n))
(or (< 4 3) (and (= 5 (+ 2 3)) (> 8 0)))
(and (+ 6 2) false)
(age-surcharge 24) [use your age-surcharge program from above]
(cond [(/ 9 4) 'divided] [(+ 9 4) 'added] [else 'neither])
cond: clause is not in question-answer format
reference to undefined identifier: x
illegal application: first term in application must be a function name
Turn in a single file hwk1.ss containing all code and documentation for this assignment. Make sure that both students' names are in a comment at the top of the file.