Assignment #7 - Student Records
Due Date: Friday, Dec 8 (FINAL Deadline)
IMPORTANT NOTE: No late submissions will be accepted for this
one. Fri, Dec 8 is the ABSOLUTE DEADLINE, in order to leave appropriate
time for grading
Objective
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.
Task
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
- The first line of the input file will be a single integer number --
this value tells how many records are in the file.
- After this, each line represents one student record. Each record
consists of the following fields (in this order), separated by commas:
- last name: a character string (assume no more than 20 characters)
- first name: a character string (assume no more than 20 characters)
- course: a single character. 'M' for math, 'H' for history, 'E' for
English. Represents the course that the student is taking.
- Test 1 grade: an integer
- Test 2 grade: an integer
- Final exam grade: an integer
- You may assume that a file is in the correct format, and that the
types and limits will be as described above
- A sample input file
Program Details
- Create a structure type called Student. A variable of type
Student should contain fields for the following:
- last name
- first name
- course
- test 1 grade
- test 2 grade
- final exam grade
- test average -- (use type double)
The other fields match the data described in the input file format
section. You may use either C-strings or string objects for the last
name and first name.
- 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.
- Open the input file and read the records into an array of Student
structures. Create this array dynamically, since we don't know
how many records are in any given file until we read a file while the
program is running. The data from each record in the file should be
stored in one Student structure (i.e. one array slot per student record)
- 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%
- Print a grade summary report to the output file, as specified below
in the "Output File Format" section
- Close the files and clean up any dynamically allocated space before
ending the program
Output File Format
- The summary report is to be sorted by course, with English first, then
History, then Math. Each course's section in the summary should have a
header, with the student detail records printed below
- The summary output of a student record should consist of:
- The student's name, in the format firstName lastName -- with
no extra punctuation between the names.
- Test Average, printed to 2 decimal places
- Letter Grade of the test average, based on standard 10-point scale
(i.e. 90-100 = A, 80-89.99 = B, etc.)
- After each course section, print the test average for the class.
(This means there will be three class averages -- one for English, one for
History, one for Math)
- See sample output file below to see the formatting
General Requirements
- No global variables
- You may use any of these libraries:
- iostream
- iomanip
- fstream
- cctype
- cstdlib
- cstring
- string
- Write your source code so that it is readable and
well-documented
- Part of assessing readability and style will be how well you break
your program into appropriate functions. You should have at
least one function in this program that takes in a Student structure,
or the array of Students, as a parameter
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
8
Bunny,Bugs,M,99,96,93
Schmuckatelli,Joe,H,88,75,90
Dipwart,Marvin,E,95,76,88
Phebus,Billy Joe Bob,M,75,72,91
Polinski,Axelrod,E,42,67,73
Lewinsky,Monica,H,60,68,51
Crack Corn,Jimmy,M,59,78,68
Kirk,James T.,E,80,68,88
Student Grade Summary
---------------------
ENGLISH CLASS
Student Name Test Avg
----------------------------------------------------------------
Marvin Dipwart 86.50 B
Axelrod Polinski 61.90 D
James T. Kirk 79.60 C
Class Average 76.00
----------------------------------------------------------------
HISTORY CLASS
Student Name Test Avg
----------------------------------------------------------------
Joe Schmuckatelli 84.90 B
Monica Lewinsky 58.80 F
Class Average 71.85
----------------------------------------------------------------
MATH CLASS
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, with the submit7 script:
~myers/csub/submit7 prog7.cpp