CSC 101 Programming Assignment 4
Computing Grades Statistics
-- REVISED --
The due date for this assignment is extended one week, from Monday May 3rd to Monday May 10th. The value of the assignment will be increased from 5% to 10% of the total class grade. Given this extension, your deliverables for this assignment include both the program code plus a program design, as described at the end of the writeup.
The program for this assignment computes statistics for students scores stored in a grades file. The file contains some header information describing the graded items for a class. Following the header information are individual student records, containing raw scores for each graded item.
The statistics computed are the mean and standard deviation for each graded item. A summary of student scores and the computed statistics are output to the terminal.
The program begins by reading the name of a scores file from the terminal. The program then reads from the grades file, which has the following specific format:
label percentagewhere N is the number of graded items. The label is a string of from one to five characters. The percentage is an integer between 1 and 100. The label is used as a column heading in the program output. The percentage is used to compute a weighted score for each graded item, as described below.
student nameThe student name is a string up to 25 characters, containing no blanks or tabs. The short id is a four-digit integer, possibly with one or more leading zeros. Each score is an integer between 0 and 100. There are as many lines of scores for each student as there are graded items.
short id
score 1
...
score N
The program output goes to the terminal, in the following form
Here are two sample runs, showing the precise input and output formats for the program. The runs show two successive versions of a grades file containing five graded items. The first sample input has one item graded; the second sample has all five items graded.
First Sample Input File (in file named grades5-1):5 1 Prog1 20 Quiz 20 Prog2 20 Mdtm 15 Final 25 ====== Baker,Ann,R 1234 100 0 0 0 0 Jones,John,M 5678 86 0 0 0 0 Smith,James,S 0999 92 0 0 0 0 Williams,Sarah 9990 100 0 0 0 0First Sample Run:Input the name of the grades file: grades5-1 Name Id Prog1 Quiz Prog2 Mdtm Final TOTAL =========================================================================== Baker,Ann,R 1234 100 20.00 Jones,John,M 5678 86 17.20 Smith,James,S 0999 92 18.40 Williams,Sarah 9990 100 20.00 STATISTICS: Mean 94.50 18.90 Standard deviation 6.81 1.36Second Sample Input File (in file named grades5-5):5 5 Prog1 20 Quiz 20 Prog2 20 Mdtm 15 Final 25 ====== Baker,Ann,R 1234 100 98 89 92 96 Jones,John,M 5678 86 78 92 81 83 Smith,James,S 0999 92 79 60 99 89 Williams,Sarah 9990 100 100 100 100 100Second Sample Run:Input the name of the grades file: grades5-5 Name Id Prog1 Quiz Prog2 Mdtm Final TOTAL =========================================================================== Baker,Ann,R 1234 100 98 89 92 96 95.20 Jones,John,M 5678 86 78 92 81 83 84.10 Smith,James,S 0999 92 79 60 99 89 83.30 Williams,Sarah 9990 100 100 100 100 100 100.00 STATISTICS: Mean 94.50 88.75 85.25 93.00 92.00 90.65 Standard deviation 6.81 11.87 17.46 8.76 7.53 8.27Note that your program must produce output that meets these specifications precisely. To clarify fully the output format, here is a version of the second sample output above with column numbers showing exactly what column each output falls on:1 2 3 4 5 6 7 1234567890123456789012345678901234567890123456789012345678901234567890123456789 Name Id Prog1 Quiz Prog2 Mdtm Final TOTAL =========================================================================== Baker,Ann,R 1234 100 98 89 92 96 95.20 Jones,John,M 5678 86 78 92 81 83 84.10 Smith,James,S 0999 92 79 60 99 89 83.30 Williams,Sarah 9990 100 100 100 100 100 100.00 STATISTICS: Mean 94.50 88.75 85.25 93.00 92.00 90.65 Standard deviation 6.81 11.87 17.46 8.76 7.53 8.27Location of Input Files
Your program will be evaluated using six input files. Two of the files are the examples presented above. The other files are similar. All of the files are located in the following directory on the central UNIX machine:The files are named grades5-1, grades5-4, grades5-5, grades2-0, grades2-2, and grades4-4-big. To see the expected output for each of these files, run the program solution on them. The solution is in~gfisher/classes/101/assignments/inputs/~gfisher/classes/101/solutions/program4
For this assignment, you must input multiple-character strings from the grades
file, and output strings to the terminal. String input and output is described
on pages 672-673 of the textbook. It is basically like single-character
input/output, but variables are declared as multi-character strings, using the
notation
char[n]
where n is the maximum number of characters in the string.
As an example of using string variables, here is a program fragment that reads
in a string as a file name, and opens the file of that name. (This is what
needs to be done at the beginning of this program.)
char file_name[50]; // File name input, up to 50 characters long
//
// Prompt for and input the name of the grades file.
//
cout << "Input the name of the grades file: ";
cin >> file_name;
cout << endl;
//
// Open the grades file, issuing an error message if it cannot be opened.
//
grades_file.open(file_name);
if (! grades_file) {
cout << "Given grades file not found or could not be opened.";
}
In addition to the electronic submission of your program code, you must turn in a program design diagram, of the style presented in Lecture Notes Week 5, Figure 3. This is a design diagram in which the names of the functions appear in the diagram boxes, and the connections between the boxes are annotated with the inputs and outputs to each function.
Your program must be implemented using the functions depicted in your design. Also, your design and implementation must obey the 25-line rule -- the body of all functions must be less than or equal to 25 lines of code, excluding comments. Officially, the body of a function includes all the lines of variable declarations and statements between the opening and closing curly braces, not including the opening and closing curly braces themselves.
To help you get started, Figure 1 on the following page is a high-level design for this program Your diagram can look similar to this, or can be as different as you'd like. Note that your diagram will be more concrete than this example, in particular:
Figure 1: High-level design diagram for Program 4.
If you have trouble implementing your solution using functions, you can turn in a version with a single main function, or a main function and a few user-defined functions. Even if you do this, you should still turn in the complete design, as your program should be implemented.
The program design must be handed in ON PAPER to the assignment drop box in front of the main Computer Science office in building 14, on or before 9PM May 10. This is the same due date and time as the electronic submission of your program code.