CSC 101 Programming Assignment 3
Computing Grades Statistics
The program for this assignment computes statistics for student scores stored in a grades file. The file contains 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 standard output. Writing the program requires that you understand the following concepts:
The program reads from a grades file, redirected from standard input. This is the same kind of file redirection we have been doing in the labs. The grades file for this program 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 (hint: %04d may help with 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. The maximum number of students is 100.
short id
score 1
...
score N
The program output goes to standard output, 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):Note 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: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:grader < 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.36
Second 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:grader < 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.27
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.27
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 program 3 directory (on vogon, copy them from ~djanzen/www/courses/101S11/projects/proj3/files/).
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 also in the proj3/files directory. You can get them with the following command:
cp ~djanzen/www/courses/101S11/projects/proj3/files/* .For this assignment, you must input multiple-character strings from the grades file, and output strings to standard output. String input and output is described in Chapter 9 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. Scanning and printing string values uses the %s formatting placeholder. Don't forget to allocate an extra space in your string for the null character.
There is a good deal of possible error checking that your program could do.
You are only responsible for checking the following specific condition:
All numeric values in the file must be non-negative integers
where N is the line number of the grades file on which the negative number is detected.Negative input on line N.
The sample executable provided outputs the error message after some successful output may have been printed. For your solution to this program, it is acceptable to have the error message printed alone, with no other output preceding the error message.
None of the six input files listed above contains any errors. You are responsible for providing input that exercises the error checking of your program. After submitted, your program will be checked with one or more erroneous grade files. These files are not provided in the samples.
You are expected to use good design principles as discussed in class and the book. Divide your solution into multiple functions. You are encouraged to write tests for your functions with the checkit_* functions as appropriate.
Be sure to follow the course Code Style, and don't forget to run
on your program before handing it in.indent -kr -nut grader.c
NO collaboration is allowed on this assignment. Everyone must do their own individual work.
You submit one program file named grader.c. Use the vogon handin command:
handin djanzen 101_prog3 grader.cComplete this survey.