CS 1101 - A-term 11

Homework 2 - Cond and Structs

Due: Tuesday, Sept 6 at 5pm

Read the expectations on homework. You will be doing this homework and all subsequent homeworks with your homework partner.

Assignment Goals


The Assignment

Programming with Cond and Structs

A company that organizes and runs conferences stores several pieces of information on the people who have registered for the conference: their name, registration category (regular, student, or member), hotel information, and whether they plan to attend the banquet dinner. Hotel information consists of the number of nights needed, what rating of hotel is requested (a number of stars from 2 to 4, inclusive), and the room type needed (double or king).

Your solutions to the following problems should use helper functions in place of repeated code. You may also introduce helper functions to improve the readability of your code.

  1. Develop data models for hotel information and conference registrants. Include both the define-structs and three examples of data for each struct that you define.

  2. In a comment in the Defintions Window, state the contracts of all the operators that are created by DrRacket for your hotel struct.

  3. Write a program registration-rate which consumes a registration category and returns the registration fee for that category. Fees are given in the following table:
          regular	$400
          member	$350
          student	$150
    

  4. Write a program hotel-surcharge which consumes hotel information and produces the total charge for that hotel request (for all nights). One night starts at $109 for a double and $89 for a king at a 2-star hotel. Rates go up $30 per night for each room type for each additional star (so a 4-star king room should cost $149 a night). Compute the charges based on the formula given, rather than by explicitly coding in the rates for each room-type and star combination.

  5. Write a program fees-due which consumes a conference registrant structure and produces the total fees due for the registration. The total fees should include the registration fee, hotel surcharge, and $40 if the person plans to attend the banquet.

  6. Write a program upgrade-hotel, which consumes a conference registration (not a hotel info) and a number (new number of hotel stars) and returns a conference registration. If the given number is larger than the number of hotel stars currently requested, the produced registration has the new number of hotel stars (and all other information the same). Otherwise, all of the information in the produced registration should be the same as in the given registration.


Grading

Here is the grading rubric that the graders will use for Homework 2.

What to Turn In

Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Follow the naming conventions for homework files. In addition, BOTH partners' names and wpi ccc usernames MUST be listed in a comment at the top of your file. Programs will not be accepted for submission after 5pm on Tuesday, Sept 6.