COP 3330 - Programming Assignment #6

Due: Friday, Apr 12

Objective

To gain experience with base and derived classes, virtual functions, and using applications of polymorphism. Also, to gain further practice with file I/O, as well as dynamic allocation.

Task

You will design a set of classes for storing student information, along with a class that will manage a list of students. Data can be imported from files for storage in the list, and summary reports with computed final grades will be printed to output files.
 

Details

  1. Design a set of classes that store student grade information. There should be one base class to store common data, and three derived classes that divide the set of students into three categories: English students, History students, and Math students. All data stored in these classes should be private or protected. Any access to class data from outside should be done through public member functions. The base class should allocate storage for the following data (and only this data):  
  2. Each class should have a function that will compute and return the student's final average, based on the stored grades. All grades are based on a 100 point scale. Here are the grades that need storing for each subject, along with the breakdown for computing each final grade:

    English -- Attendance = 10%, Project = 30%, Midterm = 30%, Final Exam = 30%

    History -- Term Paper = 25%, Midterm = 35%, Final Exam = 40%

    Math -- There are 5 quizzes, to be averaged into one Quiz Average (which can be a decimal number). Final grade computed as follows:
    * Quiz Average = 15%, Test 1 = 25%, Test 2 = 25%, Final Exam = 35%
     

  3. Write a class called StudentList, which will be used to store the list of various students, using a single array of flexible size. Note that this array will act as a heterogeneous list, and it will need to be dynamically managed. Each item in the array should be a Student pointer, which should point to the appropriate type of object. Your list should only be big enough to store the students currently in it.
    Note that the StudentList class is NOT part of the inheritance hierarchy described in the first two items above. This class is used to store and manage a LIST of individual students.

    Your StudentList class needs to have these public functions available:


    Note that while this class will need to do dynamic memory management, you do not need to create a copy constructor or assignment operator overload (for deep copy) for this class. (Ideally we would, but in this case, we will not be using a StudentList object in a context where copies of such a list will be made)
    Here is a starter file: studentlist.h with the appropriate prototypes
     
  4. Write a main program (in a separate file) that creates a single StudentList object and then implements a menu interface to allow interaction with the object. Your main program should implement the following menu loop (any single letter options should work on both lower and upper case inputs):
                     *** Student List menu ***
    
            I       Import students from a file
            S       Show student list (brief)
            E       Export a grade report (to file)
            M       Show this Menu
            Q       Quit Program
    
    The import and export options should start by asking for user input of a filename (you may assume it will be 30 chars or less, no spaces), then call the appropriate class function for importing a file or printing the grade report to file, respectively. (If the inport/export fails due to bad file, print a message indicating that the job was not successfully completed).

    The "Show student list" option should call the class function that prints the brief student list to screen (names and course info only).

    The Show this Menu option should re-display the menu.

    Quit should end the menu program. (Until this option is selected, keep looping back for menu selections).
     

  5. File formats

    Input File -- The first line of the input file will contain the number of students listed in the file. This will tell you how many student records are being imported from this file. After the first lines, every set of two lines constitutes a student entry. The first line of a student entry is the name, in the format lastName, firstName. Note that a name could include spaces -- the comma will delineate last name from first name. The second line will contain the subject ("English", "History", or "Math"), followed by a list of grades (all integers), all separated by spaces. There will be no extra spaces at the ends of lines in the file. The order of the grades for each class type is as follows:

    English -- Attendance, Project, Midterm, Final Exam
    History -- Term Paper, Midterm, Final Exam
    Math -- Quiz 1, Quiz 2, Quiz 3, Quiz 4, Quiz 5, Test 1, Test 2, Final Exam

    Output File -- The output file that you print should list each student's name (firstName lastName - no extra punctuation between), Final Exam grade, final average (printed to 2 decimal places), and letter grade (based on 10 point scale, i.e. 90-100 A, 80-89 B, etc). Output should be separated by subject, with an appropriate heading before each section, and each student's information listed on a separate line, in an organized fashion. (See example below). The order of the students within any given category should be the same as they appear in the student list. Data must line up appropriately in columns when multiple lines are printed in the file. At the bottom of the output file, print a grade distribution of ALL students -- how many As, Bs, Cs, etc.
     

  6. General Requirements

Extra Credit

Add an extra menu option to the menu program:
        O       sOrt student list
The letter 'O' option should cause the student list to be sorted alphabetically by name -- by last name, and if needed by first name (when the last names are the same). Do not change any of the stored data in the student records (i.e. don't change the stored case -- upper/lower case -- of the names in the objects). Just re-order the array in the StudentList object so that it is now alphabetized by name. The sort needs to be true alphabetical (not just the "lexicographical" default for strings).


Sample input files: (can download from links)

test1.txt

4
Bunny, Bugs
Math 90 86 80 95 100 99 96 93
Schmuckatelli, Joe
History 88 75 90
Dipwart, Marvin
English 95 76 72 88
Crack Corn, Jimmy
Math 44 58 23 76 50 59 77 68

test2.txt

2
Kirk, James T.
English 40 100 68 88
Lewinsky, Monica
History 60 72 78

Sample run

Screen input and output:  (keyboard input is underlined here to differentiate output from input)

                *** Student List menu ***
        I       Import students from a file
        S       Show student list (brief)
        E       Export a grade report (to file)
        M       Show this Menu
        Q       Quit Program
> i
Enter filename: test1.txt

> s
Last                 First                    Course

Bunny                Bugs                   Math
Schmuckatelli        Joe                    History
Dipwart              Marvin                 English
Crack Corn           Jimmy                  Math

> i
Enter filename: blah
Invalid file. No data imported

> i 
Enter filename: test2.txt

> s
Last                 First                    Course

Bunny                Bugs                   Math
Schmuckatelli        Joe                    History
Dipwart              Marvin                 English
Crack Corn           Jimmy                  Math
Kirk                 James T.               English
Lewinsky             Monica                 History

> e
Enter filename: outfile1.txt

> q

Goodbye!


Corresponding output file (outfile1.txt):
Student Grade Summary
---------------------

ENGLISH CLASS

Student                                   Final Final   Letter
Name                                      Exam  Avg     Grade
----------------------------------------------------------------------
Marvin Dipwart                            88    80.30   B
James T. Kirk                             88    80.80   B


HISTORY CLASS

Student                                   Final Final   Letter
Name                                      Exam  Avg     Grade
----------------------------------------------------------------------
Joe Schmuckatelli                         90    84.25   B
Monica Lewinsky                           78    71.40   C


MATH CLASS

Student                                   Final Final   Letter
Name                                      Exam  Avg     Grade
----------------------------------------------------------------------
Bugs Bunny                                93    94.83   A
Jimmy Crack Corn                          68    65.33   D


OVERALL GRADE DISTRIBUTION

A:   1               
B:   3
C:   1       
D:   1
F:   0


Submit your files in the usual way, through the web submission page.  Submit all source code files that you write for this program.  This should include a set of classes (base and derived), the StudentList class (studentlist.h and studentlist.cpp), and the menu program described above.