After you turn your program in for grading, I will test it using some
versions of the testInfo file that I have never shown to you.
If your program works incorrectly on any of my versions of
testInfo, you will lose substantial credit.
You will need to use an editor to make versions of testInfo 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 declare an ifstream and open testInfo with this
statement:
ifstream infile("testInfo") ;
OUTPUT:
The program is required to print a simple tabular report. Here is how the
report would have to appear if example (i) above is the contents of
testInfo:
Student Number Number Correct PASS/FAIL
1 12 FAIL
2 12 FAIL
3 22 PASS
Of course, what will be seen in the report will depend on what is in
testInfo.
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.
For help with this assignment, if you wish you may use the
functional diagram.
and/or
the solution road map
included in the assignment directory.
I want you to have the experience of writing a program that uses an array.
Therefore your program is required to 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 input file testInfo (with no filename
extension) and use the command:
ifstream infile("testInfo") ;
in your program.
Note: Depending on the computing environment in which you develop the program,
you may not understand how to give a file a name without an extension. If you
ask about it, I think I or Julie Gorman can help you figure it out.
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 (prototype) 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 the Unix epoch,
"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 testInfo 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 14 (56% right),
- one has a score of 15 (60% right),
- one has a score of 16 (64% right), and
- one has a score of 25 (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 testInfo for testing:
- Make a file in which numStudents = 0, and call it testInfo_0.
- Make a file in which numStudents = 1, and call it testInfo_1.
- Make a version of testInfo file in which numStudents is larger than five
and call it testInfo_L.
- When you want to run the program with testInfo_0 as the input,
just do the command
cp testInfo_0 testInfo
first
(this causes testInfo to be a copy of testInfo_0) and then run the
program.
- When you want to run the program with testInfo_1 as the input,
just copy testInfo_1 to testInfo with the command
cp testInfo_1 testInfo
first.
- When you want to run the program with testInfo_L as the input,
just do the command
cp testInfo_L testInfo
first.
Remember: I am requiring that you write the program so that it assumes that
the input is contained in a file named testInfo. If you employ the
strategy described above then you can test different versions of
testInfo 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.)