CS 1101 - Aterm 10

Homework 2 - Defining Structs

Due: Tuesday, September 7 at 5:00pm

Read the expectations on homework. Do NOT do this homework with your homework partner...You will be doing this homework individually.

Assignment Goals


The Assignment

The Registrar's office at a local college maintains a database of student records. In this assignment, you will develop data definitions and functions for student records.

Remember that all functions should have a contract and a purpose, and should be tested using check-expect.

Problems

  1. A student record is specified as follows: the student's name, ID number, home address, year of graduation, grade point average, and number of credits earned so far. The home address consists of a street, city, state, country, and zip code (or postal code).

    Develop a data definition for a student record and an address. The data definition consists of the define-struct's needed to model your definitions, and the accompanying documentation. Provide three examples of each type of data definition.

  2. In a comment in the definitions window, state all of the operators (with their contracts) that DrRacket defines as a result of your define-struct's in the previous question.

  3. Write a function deans-list? that consumes a student record and returns true if the GPA of the student is 3.5 or higher. Otherwise, the function returns false.

  4. Write a function credits-to-graduate that consumes a student record and the total number of credits required for graduation, and produces the number of credits the student has left to meet the graduation requirement. (For example, if 120 credits are required for graduation, and the given student has earned 90 credits so far, the function should produce the value 30.)

  5. Write a function add-credits that consumes a student record and a number of credits and produces a student record. The student record that's returned is the same as the original, except that the given number of credits have been added to the student's total.

  6. Write a function update-address that consumes a student record and an address and produces a student record. The student record that's produced contains the updated address information.

  7. Write a function delay-graduation that consumes a student record and a threshold value for a GPA. The function returns a student record. If the GPA of the given student is below the given GPA, then the student's year of graduation is increased by one. Otherwise, the student record is returned unchanged.

  8. The Registrar's office is considering adding the student's date of matriculation to the definition of a student record. But before they make this change, they want their programmers to first define a data definition for (and write functions for) a date.

    Develop a data definition for a date, consisting of a month, day, and year. Give three examples of dates. Then write a function earlier-date that consumes two dates and returns the one that occurs earlier.


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. Name your file

yourLastName-hw2

For example, if your name is Jane Doe, you would name your file doe-hw2. In addition, your name and your wpi ccc username must appear in a comment at the top of the file. Programs will not be accepted for submission after 5pm on Tuesday, September 7.