When I test your program, some of the versions of testData
that I test it on will be files I have never shown to you. If your
program works incorrectly on any of my versions of testData,
you will lose substantial credit.
You will need to use an editor to make versions of testData for
your testing.
If you like, you may cut and paste sequences of letters from
this file.
I generated these letters by writing a program that uses the random()
function.
OPENING THE INPUT FILE:
Your program will open testData with this statement:
ifstream infile("testData") ;
OUTPUT:
The program counts how many correct answers each person got. The program
prints a simple tabular report. Here is how the report must appear if
example #1 above is the contents of testData:
Student Number Number Correct PASS/FAIL
1 7 FAIL
2 6 FAIL
3 16 PASS
Of course, what will be seen in the report will depend on what is in
testData.
The column headings must be as shown. The spacing does not have
to be identical, but the report must be very tidy and readable.
The student numbers, from 1 to numStudents, must appear in the first
column. (Sorry, but it is not OK for the numbering to start at 0,
even though C++ arrays start at index zero. You must be careful to adjust
the numbering.)
The next column must show the number of correct answers for each student.
The last column contains the word PASS or FAIL, depending on whether the
student got 60% or more correct.
THE DESIGN OF THE PROGRAM:
There must be at least three functions in the program (including
main). There must be at least two functions that have
one or more parameters. You may find you get a better design if
you use more than three functions.
You must create your own design of this program. I am expecting
you to employ good principles of top-down design. Substantial
credit will be withheld if you do not create a program that uses
functions appropriately.
Some particulars:
- Make sure that each function does one thing well.
- Put no more than one return statement in any function.
- Use exit() statements sparingly -- no more than one in each
function.
I want you to get the experience of writing a program that uses an array.
Therefore I am requiring that your program use an array to store the
key. You may use more arrays if you wish.
Because I am going to test all the programs by compiling and running them on
different versions of the input file, I need everyone in the class to use
exactly the same name for the input file. Therefore,
please name your file testData and use the command:
ifstream infile("testData") ;
in your program.
To see some C++ code with similarities to the code you need to write, look
at the
sample program
that reads and prints golf scores.
Note: Come to class to get more discussion of how to design the program.
FORM AND FORMATTING REQUIREMENTS:
Write appropriate header comments for each of your functions. Header
comments are the comments that appear at the beginning of the function,
telling what it's purpose is and what the preconditions and postconditions
are, and so forth. You may pattern your header comments after the example
code in your text book, or you may use
this information
as your guide.
At the beginning of your program file put a header comment like
this:
/* PROGRAM Batting Statistics */
/*
Name: Gordon Goodguy
User Name: goodge
Course: CS 1500, Computer Programming I
Instructor: John Sarraille
Date: January 01, 1970
*/
Of course, in place of "Gordon Goodguy," you must put your own full name.
In place of "goodge" put your user (login) name. In place of "January 01,
1970" put the date that you finished the program. Note that the comment
delimiters /* and */ are important. They need to be placed correctly or you
will get compiler errors.
TESTING:
Since the specifications allow numStudents to be zero, you will need to make
at least two versions of testData for testing.
Here's a nice way of managing different versions of testData for testing:
- Make a file in which numStudents is zero, and call it
testData01.
- Make an "average" version of a testData file and call it
testData02.
- When you want to run the program with testData01 as the input,
just do the command
cp testData01 testData
first.
- Similarly, when you want to run the program with testData02 as
the input, just do the command
cp testData02 testData
first.
WHAT TO TURN IN:
Before midnight on the due date, e-mail the following two items
to me:
- A copy of the source code, properly documented.
- A filtered script showing an appropriate number of
test runs with appropriate inputs.
My e-mail address is:
john@ishi.csustan.edu
Please use the following subject lines exactly for the
e-mails:
For the source file: CS1500_Solo6_Source
and for the script file: CS1500_Solo6_Script.
Note that there are no spaces in these subject lines. If you like, you can
copy and paste the subject lines right from this document.
Thanks! Your use of these subject lines will really be a big
help to me when I try to sort through the perhaps hundreds of e-mail messages
that will be in my electronic mailbox!
WHEN IS THIS ASSIGNMENT DUE?
Look for the due date in
the class schedule.
(It's at the top level of the class directory.)