( Latest Revision: 11/24/2004 )

SIXTH CS 1500 SOLO PROGRAM: Grading Program


OBJECTIVE: The purpose of this programming assignment is to get practice using files, arrays, and for-loops.


ASSIGNMENT SYNOPSIS:

Write a program that grades a multiple choice exam.


INPUT:

You must write the program with certain facts, assumptions, and preconditions in mind: 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: 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: 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 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: 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: Here is the list of things you have to turn in: 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.)