Be sure to refer to the Laws of Homework when preparing your solutions.
A cellular phone company defines different service plans around three pieces of information: the region in which the plan is active, the number of minutes included, and whether the plan includes text messaging. The company defines three regions: Massachusetts, New England, and Nationwide.
Develop a data model for service plans. Include the define-struct needed to model plans and three examples of plans 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 customer subscriptions for cellular service. A subscription contains the customer's name, number, service plan, and a discount code (one of none, long-dist-cust, or long-term-cust). Include the define-struct needed to model your subscriptions and three examples of data created with your model. You may choose/design your own data model for phone numbers (but be sure to document it if it's not a built-in kind of data!).
Write a program regional-rate
which consumes a
region and returns the monthly rate for that region. Regional rates are
according to the following table:
mass | $19.95 |
new-england | $29.95 |
usa | $39.95 |
Write a program minutes-surcharge
which consumes
a number of minutes (assume non-negative) and returns the rate for
that number of minutes. The first 300 minutes are free. Each 200
minutes beyond the first 300 costs $12. Your program should return
only whole-number multiples of 12. For example, 301 minutes costs
$12, 500 minutes costs $12, and 600 minutes costs $24.
Write a program discount
which consumes a type of
description (a symbol) and returns a number representing the
percentage saved on a plan under the indicated program. The returned
percentages should follow the table below:
long-dist-cust | 5% |
long-term-cust | 3% |
none | 0% |
Write a program subscription-rate
which takes a
subscription and returns the total rate for that subscription. The
subscription rate applies the discount to the combination of the
regional rate and the minutes surcharge. Text messaging costs $3
extra and is not discounted.
Write a program install-discount
, which consumes
a subscription and a discount code and returns a subscription with the
same name, number, and plan as the original subscription, but with the
given (new) discount code.
(sqrt (+ (* 3 3) (* 4 4))) ^^^^^^^ = (sqrt (+ 9 (* 4 4))) ^^^^^^^ = (sqrt (+ 9 16)) ^^^^^^^^ = (sqrt 25) ^^^^^^^^^ = 5If an expression would result in an error, show all of the steps up to the error, then indicate the error message you'd get (error messages don't need to be verbatim, as long as they convey the right kind of error).
(/ (- (* 16 16) (double a)) 2) where double is defined as (define (double n) (* n 2))
(or (< 7 2) (and (= 15 (- 18 3)) (> 8 4)))
(and (+ 9 -1) false)
(regional-rate 'new-england) [use your regional-rate program from above]
(cond [(- 5 2) 'subtracted] [(* 5 2) 'multiplied] [else 'neither])
cond: expected a clause with a question and answer, but found a clause with only one part
reference to undefined identifier: x
function call: expected a defined name or a primitive operation name after an open parenthesis, but found a number
Turn in a single file hwk1.ss or hwk1.scm containing all code and documentation for this assignment. Make sure that both students' names are in a comment at the top of the file.