UMBC CS 201, Fall 05
Programming Project Three
Out: Sunday 10/30/05
Due: Before Midnight, Sunday 11/13/05
Sun Nov 13 23:59:59 EST 2005 is on time, but one second later the date
command will show
Mon Nov 14 00:00:00 EST 2005, which is midnight and your project will be worth
0 points at that time and later.
The design document for this project, design3.txt,
is due: Before Midnight, Monday 11/06/05
A sample design document is available from the main Projects page.
Engineering Change Notices
- ECN 1 further specifies input guarantees
for project 3. It includes guarantees about the contents of the
data file and also about user input.
The objective of this assignment is to give you practice with arrays of
structs, working with characters as input, file-handling, dynamic memory
allocation, working with strings, passing by reference, command-line arguments,
and, of course, design and separate compilation.
You have been hired by the CSEE department as the CMSC 201 gradeskeeper. One
of your responsibilities is to generate reports. There are basically two
different kinds of reports. One type, called stats, gives the breakdown of the
number of students by major, by sex, by class (freshman, sophomore, junior,
senior) and by section. (I will give an example stats report.)
The other type of report is a grade report. Grade reports can be created for
an individual student, all the students of a specific section, or all students
in the class. You are to to write a program that prints out these reports
(TO AN OUTPUT FILE ONLY - NOT TO A PRINTER ), using the data found in the
file called p3students.dat.
In order to use your program, the person generating the reports should enter
the name of the executable and the name of the data file to be used as input
on the command line. The input file is called p3students.dat, in this case.
At this point the user should be presented with a greeting and then a main
menu that allows him/her to choose the type of report to generate or to quit.
Your greeting goes here
S - Statistical report
G - Grade report
Q - Quit
Enter your choice :
After choosing any of these options, the appropriate action should take place
and then this menu should be presented to the user again. The user must choose
Q from this menu to end the program. Similarly, the user should always be
returned to the grades menu until s/he chooses 'R' to return to the main menu.
- where choosing 'S' will immediately start generating the statistical
report, which should be written to a file called stats.txt.
- choosing 'G' will present the user with another menu, where s/he may
and choosing 'Q' allows the user to quit.
- ' I ' to create a grade report for an individual student
- 'S' to select a section and genetate reports for all students
enrolled in that section
- 'A' to generate a grade report with averages by section and
for the class as a whole or
- 'R' to return to the main menu.
The records of the students are kept in ascending sorted order by login name
and has the information stored separated by spaces for each record in the
login(max of 8 chars) lastName(max of 15 chars) firstName(max of 15 chars)
sex(char) major(max of 4 chars) section(max of 5 chars) class(max of 2 chars)
proj1(int) proj2(int) proj3(int) proj4(int) proj5(int) lab1(int) lab2(int)
lab3(int) lab4(int) lab5(int) lab6(int) lab7(int) lab8(int) lab9(int)
lab10(int) lab11(int) lab12(int) midterm(int) finalExam(int)
The file begins with a single integer which is the number of student records
in the file. Here's an example of an input file's format:
dblock Block Dawn F CMSC 0101 SO 84 91 94 82 99 3 3 2 3 3 3 3 2 3 3 3 3 95 92
sbogar1 Evans Sue F CMSC 0201H SR 85 92 95 83 100 3 3 2 3 3 3 3 2 3 3 3 3 91 93
Design Limitations and Details
- You are required to use separate compilation for this project. The
file that contains main() is to be called proj3.c. You must
also have a students.c and the associated students.h file. You might
want to use your util.c and associated util.h if you have any general
functions that you want to add to them, or reuse some functions that
you may already have there. The number of files you use is up to you,
but functions need to be grouped appropriately and placed in files
whose names reflect the purpose of the functions grouped there. If you
are using your util.c file for this project you do NOT remove function
definitions from it that aren't being used in the current project.
Just leave them in.
- You MUST use dynamic memory allocation (malloc or calloc) to allocate
the memory to hold the array of structures after you have read the
number of records from the file.
- You must read the entire contents of the input file, load the data
into an array of structs and close the file before presenting the
initial menu to the user.
- Menus must accept either uppercase or lowercase versions of the letters
specified. So S, s, G, g, Q, & q are acceptable for the main menu
and I, i, S, s, A, a, R, & r are acceptable for the grades menu.
- All reports should print to files. DO NOT send reports to a
- The statistics report should be written to a file called stats.txt.
- There are several kinds of grade reports.
- A grade report for an individual student, whose login name is
dblock, should be written to a file called dblock.txt.
It should include a report of all her grades and her total
course score and letter grade. The course score can be
determined by the following:
- Each lab score is out of 3 points and each of the 10 best
labs counts as 1% of the total score. (lowest 2 labs are
- Each project is worth 8% of the grade and is based on a
score of 100.
- Each exam grade is worth 25% of the grade and is based on
a score of 100.
- The letter grade is assigned without a curve, so an A is
assigned to a course score of 89.5 and above, a B for scores
between 79.5 and 89.4, etc.
- A grade report for an entire section, should consist of
individual grade reports for each student in that section
separated by a long line of dashes, as in:
and a section report that gives the section averages for
each lab, project, and exam as well as the average total
score for the students in that section. These reports
should be written to a file that is named by the section
number, i.e. 0101.txt.
- A grade report for the entire class should be composed of
section reports separated by lines of dashes and the class
averages for each lab, project and exam, as well as the
average of the total scores for the entire class. This
report should be written to a file called
- The individual grade report filenames, must be composed using string
- You MUST have a function called CalculateStats() that has the following
void CalculateStats(STUDENT* students, int numStudents,
int* pMale, int* pFemale,
int* pCmsc, int* pCmpe,
int class, int numClasses,
int sections, int numSections);
that uses call by reference to modify the number of males, females,
CMSC majors and CMPE majors known in the calling function.
You may NOT modify this prototype.
- You must close all files as soon as you are finished either reading from
them or writing to them.
- On normal (non-error) execution of the program, you must free all memory
that you allocated dynamically.
- As always, you will be graded on your design as well as the correctness
of your program, documentation and style.
A Short Sample Run
linux2 % ls
proj3.c students.c students.h typescript util.c util.h
linux2 % gcc -c -Wall -ansi proj3.c
linux2 % gcc -c -Wall -ansi students.c
linux2 % gcc -c -Wall -ansi util.c
linux2 % gcc -Wall -ansi proj3.o students.o util.o
linux2 % a.out p3students.dat
Your greeting goes here
S - Statistical report
G - Grade report
Q - Quit
Enter your choice : T
T is not a valid choice
Enter your choice : s
S - Statistical Report
G - Grade Report
Q - Quit
Enter your choice : q
Sample Statistical Report
Statistics Report for CMSC 201
students : 25
Sex: male : 19 76.0 %
female : 6 24.0 %
Major: CMSC : 13 52.0 %
CMPE : 5 20.0 %
other : 7 28.0 %
Class: freshmen : 8 32.0 %
sophomores : 11 44.0 %
juniors : 4 16.0 %
seniors : 2 8.0 %
Section: 0101 : 6 24.0 %
0102 : 6 24.0 %
0103 : 4 16.0 %
0104 : 5 20.0 %
0201H : 4 16.0 %
Copying the file
The file you need to use for this project is
p3students.dat You may get a copy of this file from my account. The file
is in the /afs/umbc.edu/users/s/b/sbogar1/pub directory.
The executable and the data file need to be in the same directory when you
run the program. The command to copy the file is:
cp /afs/umbc.edu/users/s/b/sbogar1/pub/p3students.dat .
Note that there are three parts of the command separated by spaces. The last part is
a period (with a space before it), which says copy the file to current directory.
Submitting the Program
To submit the files you should use the command:
submit cs201 Proj3 proj3.c students.c students.h (followed by any
other .c and .h files your project needs to be compiled)
Do NOT submit p3students.dat nor any of your output files (stats.txt, or any
other *.txt file).
You can check your submission by using the command:
submitls cs201 Proj3
Sunday, 06-Nov-2005 19:29:37 EST