Cell Service Plans
posted by: Ms. Martin
19 September 2010
One Comment
Thanks to Kathi Fisler, professor at WPI, for the assignment this is based on.
The Goals
- Use structs to model complex information
- Practice writing data definitions
- Practice using the design recipe for structs
The Assignment
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: Puget Sound, Pacific Northwest, 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.
- 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-ratewhich consumes a region and returns the monthly rate for that region. Regional rates are according to the following table:
Puget Sound $19.95 Pacific Northwest $29.95 Nationwide $49.95 - Write a program
minutes-surchargewhich consumes a number of minutes (assume non-negative) and returns the rate for that number of minutes. The first 150 minutes are free. Each 250 minutes beyond the first 150 costs $12. Your program should return only whole-number multiples of 12. For example, 151 minutes costs $12, 400 minutes costs $12, and 500 minutes costs $24. - Write a program
message-surchargewhich consumes a discount code and returns a number representing the rate for text messaging under that code. The rates should follow the table below:
long-dist-cust $3.95 long-term-cust $0 (free) none $5.95 - Write a program
subscription-ratewhich takes a subscription and returns the total rate for that subscription. The subscription rate is the total of the regional rate, minutes surcharge, and messaging surcharge. The messaging surcharge should be 0 if the plan does not include messaging. - Write a program
enable-messaging, which consumes a subscription and returns a subscription with the same name, number, and discount code as the original subscription, but with a plan that includes text messaging.






