After you turn your program in for grading, I will test it using some
versions of the testData file that 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 created this file of letters with a program that uses a "pseudo-random
number generator" -- a C++ library function named random.
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
(i) 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.
I expect you to employ good principles of top-down design when you create your
program. 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.
- Don't use any global variables.
There is a simplified functional diagram you could use for the design of your
program
here.
There are no return-types or parameters shown in the diagram. That's because
I don't want to give you that information. I want you to decide what
return-types and parameters your functions should have.
I also 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 function declaration comments for each of your functions.
These are comments placed under each function declaration to explain the
purpose of the function, and to explain what the function does. Read the
comments in the example programs in your book, and write similar comments for
your functions.
At the beginning of your program file put a header comment like
this:
/* PROGRAM: Test Grader */
/*
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:
I want you to make at least three different versions of the file testData with
which to test your program:
- one in which numStudents = 0;
- one in which numStudents=1; and
- one in which numStudents is a number larger than five
In the last file - the large one - there will be several lines of letters
after the integer numStudents. Each of those lines represents the answers
that one student gave on the test. You must write that last file so that
- at least one of the students has a score of 0 (100% wrong),
- one student has a score of 11 (55% right),
- one has a score of 12 (60% right),
- one has a score of 13 (65% right), and
- one has a score of 20 (100% right).
When you do your testing, make sure that all the output of the program is
correct.
Here's a nice way of managing different versions of testData for testing:
- Make a file in which numStudents = 0, and call it testData_0.
- Make a file in which numStudents = 1, and call it testData_1.
- Make a version of testData file in which numStudents is larger than five
and call it testData_L.
- When you want to run the program with testData_0 as the input,
just do the command
cp testData_0 testData
first
(this causes testData to be a copy of testData_0) and then run the
program.
- When you want to run the program with testData_1 as the input,
just copy testData_1 to testData with the command
cp testData_1 testData
first.
- When you want to run the program with testData_L as the input,
just do the command
cp testData_L testData
first.
Remember: I am requiring that you write the program so that it assumes that
the input is contained in a file named testData. If you employ the
strategy described above then you can test different versions of
testData without difficulty.
WHAT TO TURN IN:
You will be sending me two e-mail messages. Please follow these rules:
- Always send me e-mail as plain text in the main message body.
Never send me attachments.
- Always use the exact subject line I specify for each
message. (I often get hundreds of e-mail messages in a week. The
subject line allows me to find and sort messages.) You will lose a
significant number of points on the assignment if you use the wrong
subject line.
- Be very careful when you send the e-mail. You may use the
instructions in your
Hello World! lab exercise
for guidance. Of course, you will need to make the obvious changes to
those directions -- you have to use the correct subject line and
filename.
- Always send yourself a copy of each e-mail message you send to me,
check immediately to see if you receive the message intact, and
check within a few minutes to see if you have received e-mail notifiying
you about an undeliverable message. You are
responsible for sending e-mail correctly.
Here is the list of things you have to turn in:
- At the start of class on the
due date
place the following item on the "counter" in front of me:
- a hardcopy (printed listing) of your program (the C++
source code). Make sure all the code is properly
formatted and that it all shows on the paper.
- Before midnight on the the due
date send me the following by e-mail:
- A copy of the source code (C++ code) with subject line:
CS1500Solo6Source
- a (filtered) script, with subject line
CS1500Solo6Script
showing (at least) the results of running the program on the three
input files described above in the section entitled "TESTING"
Note that there are no spaces in the subject lines given. It is important
that you do not insert any spaces. My e-mail address is:
john@ishi.csustan.edu
WHEN IS THIS ASSIGNMENT DUE?
Look for the due date in
the class schedule.
(It's at the top level of the class directory.)