CSC 533: Organization of Programming Languages
Fall 2003

HW1: C++ Programming


For this first assignment, you are to write a C++ program that might serve as an aid to student advisors. Given a collection of class rolls, your program should allow the advisor to extract a list of all the courses taken by a given student.

Your program should first prompt the advisor for the file name where the class rolls are stored. Once the name is obtained, the program should read in and store the registration information. The format of the file is up to you, but it should be able to represent a course name and list of students for each course. For example:

CSC107: Joe College, Mary Creighton, Billy Bluejay CSC533: Bill Gates, Steve Jobs MTH245: Billy Bluejay, Mary Creighton HIS101: Mary Creighton, Billy Bluejay PHY107: Bill Gates, Mary Creighton

There is no preset limit on the number of students in a course, or the number of class lists that may appear in a file. Once the class rolls have been read in and stored, the advisor should be prompted for a student name. Then a list of all courses taken by that student should be displayed. For example, given the above class rolls, a search for Mary Creighton should display CSC107, MTH245, HIS101, and PHY107 (in some readable format). If the student is not registered for any classes, then a message to that affect should be displayed. The advisor should be repeatedly prompted to allow for multiple searches, finally terminating the program when the advisor specifies no more searches are desired.

You are being given considerable freedom in designing this program. The format of the class-rolls file, the choice of data structures for storing the class rolls, and the I/O interface are yours to design. However, your interface should be clear to the user so that they know how to enter information, and your data structures should provide reasonable access to the required data. Your grade for the assignment will depend not only on its correctness, but also on the elegance of your code.

If you would like a quick review of useful C++ classes and libraries (some of which may be new to you), see CSC533 REVIEW SHEET: C++ Classes & Libraries.

<Four sample solutions>