CS 1101 - A-term 15

Homework 4 - Writing functions for Lists of Structs

Due: Thursday, September 24 at 5pm

Read the expectations on homework.

Assignment Goals


The Assignment

Many high schools require that students complete a number of hours of community service prior to graduation. In this assignment, you will write data definitions and functions that model a database of volunteer opportunities that are available through a high school guidance counseling office.

  1. Each type of volunteer organization records the following information: the type (animal shelter, nursing home, soup kitchen, etc.), the name of the organization, the minimum age requirement for volunteers, whether or not parental consent is required if the volunteer is under 18 years of age, whether or not the volunteer must hold a valid driver's license, the number of hours of training required for volunteers, the minimum number of hours of volunteer work required per week, and a list of languages spoken by clients of the organization. Define a struct called volunteer-org that represents the given information. Give at least 3 examples of volunteer-org's.

  2. Write the template(s) for functions over volunteer-org's.

  3. Define a ListOfVolunteerOrg. Give at least two examples of such lists.

  4. Write the template for functions over ListOfVolunteerOrg.

As you develop the following functions over ListOfVolunteerOrg, develop auxiliary (helper) functions over volunteer-org's.

  1. The guidance office wants to determine how many of the organizations will accept volunteers of any high school age (13 years or above). Develop the function count-hs-eligible, that consumes a ListOfVolunteerOrg and returns the number of organizations in the list for which the minimum age for volunteering is 13 or younger.

  2. Some students at the high school have driver's licenses, but can't commit to a long training program. Develop a function list-license-training that consumes a ListOfVolunteerOrg and a natural and produces an ListOfVolunteerOrg. The list that is produced contains only those items from the original list that require volunteers to be licensed, and require fewer than the given number of training hours.

  3. Develop a function languages-spoken that consumes a ListOfVolunteerOrg and produces a ListOfString. The function lists all the languages spoken by clients of all the organizations. It's OK if languages are listed more than once.

  4. Several students from the AP Spanish class would like to volunteer at an organization where they can put their Spanish skills to good use. Develop a function need-spanish-speakers. The function consumes a ListOfVolunteerOrg and produces a list of only those volunteer organizations who have clients who speak Spanish.


What to Turn In

By now you should know what we expect from you on the homework, so the grade sheets will no longer be available in advance. Note that programs must run to receive credit, and that code that is commented out will not be graded.

Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Follow the naming conventions for naming your file.