Assignment #7 - Student Records

Due Date: Tues, Aug 3


To gain experience with using an array of structures, as well as with dynamic allocation of an array. This program provides further practice in file input/output, as well.


You will write a program that reads and stores student data from an input file, computes and stores each student's test average, then prints a report to an output file, along with class averages.

Input File Format

Program Details

  1. Create a structure type called Student. A variable of type Student should contain fields for the following: The other fields match the data described in the input file format section. Use C-strings for the last name and first name.
  2. Your program should start by asking the user to type the names of the input and output files (in that order). Whenever a bad filename is entered, print an error message and prompt the user to re-enter the filename.
  3. Open the input file and read the records into an array of Student structures. You'll need to create this array dynamically, because you won't know how many records there are until you start reading the file itself. The data from each record in the file should be stored in one Student structure (i.e. one array slot per student record)
  4. For each student, compute the test average and store it in the test average member variable for that student struct. The test average should be computed according to the following weights for the tests:
     Test 1:      30%
     Test 2:      30%
     Final Exam:  40%
  5. Print a grade summary report to the output file, as specified below in the "Output File Format" section
  6. Close the files and clean up any dynamically allocated space before ending the program

Output File Format

General Requirements

Extra Credit

Within each subject in the output file, list the students in alphabetic order, sorted by last name. Do not change the given case (upper/lower case) of the names that were read from the input file when you print the output file. However, this sort needs to be true alphabetical (not just the "lexicographical" sort).

Sample Program Run

Here is one sample program run, on the sample input file linked previously. Note that this is just one example. You can (and should) create your own test cases to test this program more fully. The keyboard/screen interaction is shown first (keyboard input is underlined), then the sample input file and output file contents are shown.
Please enter the name of the input file.
Filename: test1.txt
Please enter the name of the output file.
Filename: outfile1.txt
Processing Complete

Sample Input File

Phebus,Billy Joe Bob,M,75,72,91
Crack Corn,Jimmy,M,59,78,68
Kirk,James T.,E,80,68,88

Output File Contents (after the program run)

Student Grade Summary


Student Name                             Test Avg
Marvin Dipwart                              86.50    B
Axelrod Polinski                            61.90    D
James T. Kirk                               79.60    C

		Class Average               76.00


Student Name                             Test Avg
Joe Schmuckatelli                           84.90    B
Monica Lewinsky                             58.80    F

		Class Average               71.85


Student Name                             Test Avg
Bugs Bunny                                  95.70    A
Billy Joe Bob Phebus                        80.50    B
Jimmy Crack Corn                            68.30    D

		Class Average               81.50

Submit your program (Use the filename prog7.cpp) in the usual way, through the web page.