CSC 101 Programming Assignment 3
Computing Grades Statistics



DUE: On or before 11:59:59PM Monday 9 May, via handin on vogon

Overview

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:

Specification

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:

The program output goes to standard output, in the following form:

Sample Inputs and Outputs

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
0
First 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
100
Second 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
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:
         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

Location 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 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/* .

String Input and Output

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.

Error Checking

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


Upon detecting the first negative numeric value, the program outputs the following message, and terminates immediately with no further processing:
Negative input on line N.
where N is the line number of the grades file on which the negative number is detected.

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.

Function Decomposition and Automated Unit Tests

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.

Code Style

Be sure to follow the course Code Style, and don't forget to run

indent -kr -nut grader.c
on your program before handing it in.

Collaboration

NO collaboration is allowed on this assignment. Everyone must do their own individual work.

Program Turnin Procedure

You submit one program file named grader.c. Use the vogon handin command:

handin djanzen 101_prog3 grader.c
Complete this survey.