YALE UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
| CPSC 223b: Data Structures and Programming Techniques | Handout #16 | |
| Professor M. J. Fischer | April 8, 2007 | |
Problem Set 9
Due before midnight on Tuesday, April 24, 2007.
A university has a policy of rolling admissions. Students apply, receive offers of admission, and either accept or decline the offers. At any given time, there is a pool of students who have received offers of admission but have not yet accepted or declined the offers.
This university has a limited number of merit-based scholarships which it uses to attract and retain top students. Students are eligible for the scholarship only if they have been admitted, have not already been offered a scholarship, and have a combined SAT score of at least 1100. Scholarships are awarded on a rolling basis. Whenever a scholarship becomes available, it is offered to the eligible student in the pool with the highest SAT score. Ties are broken in favor of the student who was admitted first. If there are no eligible students, any unassigned scholarships are held in abeyance until additional eligible students are accepted.
Admissions data is furnished to the program in the form of an actions file, each line of which describes an admissions action or event. The four kinds of actions are:
An admit line comprises four whitespace-separated fields:
It is an error if the ID collides with the ID of another student in the pool.
Example:
admit "Kevin Massey" 2007F0003 1423
|
An accept line comprises two whitespace-separated fields:
It is an error if the ID does not match any student in the pool.
Example:
accept 2007F0003
|
A decline line comprises two whitespace-separated fields:
It is an error if the ID does not match any student in the pool.
Example:
decline 2007F0003
|
An available line comprises two whitespace-separated fields:
Example:
available 5
|
The goal of this assignment and the next is to write a program that manages and assigns scholarships to students according to the rules described above. The program should print a line of output whenever the following events occur:
In the first three cases, the line printed should begin with the words “Scholarship event” followed by the student’s name, ID number, and SAT score, where event is replaced by “offered to”, “accepted by”, or “declined by” as appropriate. For example, when John Smith is offered a scholarship, the following would be printed:
Scholarship offered to John Smith (ID=2007F0001, SAT=1350)
|
When new scholarships become available, a line should be printed showing the number of new scholarships and the total number of unfilled scholarships, including the new ones. For example, if there were two unfilled scholarships and a student with a scholarship declined, the following line would be printed:
1 new scholarships, 3 unfilled
|
Note that a scholarship released by a student who declines is considered to be “new”.
When end of file is reached, the program should print out the following data:
Using the data structures from problem set 8, write a command action that reads admissions action data from a file, awards scholarships as described in sections 1–2, and produces output as described in section 3.
Your program as usual should be built from several modules.
You are encouraged to make use of code previously written in this course. For example, flexbuf of problem set 4 is useful for reading lines from the admissions data file.
I will place sample input and output files in in the course directory
They will be useful for the initial testing of your program, but they are by no means complete. In particular, you should include tests that have unassigned scholarships at the end, tests that have eligible students waiting for scholarships, tests that show the scholarships are indeed being offered to the highest priority students when there is a choice, and so forth.
You should submit source code and a Makefile for all of your modules (including symtab and heap) along with test input and output files which test your code as well as possible.