Computer Science 1511
Computer Science I

Programming Assignment 8
Structures (35 points)
Due Friday, December 17, 1999 (at 4:00 PM, NO late programs)

Introduction

In this lab you will implement a simple program for recording a set of data. You should declare an array of structure objects as the basic data structure for this assignment.

The Problem

Rachel wants to keep track of the classes she has taken so that she can easily display the information and manipulate it. For each class she wants to record the following things:

She expects to take at most 50 classes in her career and does not expect to take any class twice. She wants to be able to perform the following operations on her set of classes:

How To Proceed

Your program should consist of a set of menu options and a switch statement to execute the option chosen by the user:

Options:
  A)dd course
  D)elete course
  P)rint courses
  calculate G)PA
  Q)uit
Your option:

This would be implemented with code something like this:

  do {
    PrintMenuOptions(); /* Print out menu choices above */
    scanf(" %c",&option);
    fflush(stdin);
    switch (option) {
      case 'A': case 'a':  /* Call function to add course */
      case 'D': case 'd':  /* Call function to delete course */
      case 'P': case 'p':  /* Call function to print courses */
      case 'G': case 'g':  /* Call function to calculate GPA */
      case 'Q': case 'q': break;
      default:
        printf("Unknown option |%c|!!\n",option);
        break;
    }
  } while ((option != 'Q') && (option != 'q'));

Next you should pick a data structure. Make sure that your data structure deals with all possible classes. Add a typedef for this data structure at the top of your program.

Implement the program routines one at a time. I suggest you start with the routines to add and print courses. Once these are done you can use them to test the other routines.

What To Hand In

Hand in a full lab report for your program. Also show output for your program testing various aspects of your program. To test that your program won't allow Rachel to enter too many classes you may want to change the class limit to a much smaller number (like 5).

Extra Credit

5 points - Add two functions, one at the start of your program and one at the end. The function at the end should print out all of the courses that are currently in the set when the program ends. The function at the beginning of the program should read in this data (so that Rachel doesn't have to start over entering courses).

3 points - Maintain the courses in sorted order by department first and then by course number (e.g., Chem 1150 comes before CS 1511 and CS 1521 comes before CS 4611). Your routines should take advantage of this information when the delete routine is implemented.

3 points - Print out a GPA/credit breakdown by department. When printing out the GPA, also print out the GPA for courses within each department and how many credits of courses the student has taken in that department. Note that courses that are failed (grade of F) should not be counted when determining how many credits a student has in a department but theses courses should be used in calculating GPA.

20 points - Implement an alternate version of your program (you should implement and test it both ways) using a linked list rather than an array of structures.