Solution Roadmap



#include <fstream>
#include <iostream>
#include <iomanip>
#include <assert.h>   

using namespace std ;

int main(void)   
{   
   /*
      Declare and open input file.

      Declare array for the key.

      Call getKey to copy the key from the file to the array.

      Call makeRepTitles to make the headings on the screen.

      Call doGrading to do the grading and put the results on the screen.

   */
   return 0;
}   

void makeRepTitles()
{
   /*
      Write code here that puts the following on the screen:
      Student Number      Number Correct       PASS/FAIL
      (put the appropriate number of blank lines before and after.)
   */
}

void getKey (char key[], ifstream & infile)
{
   /*
      Declare a loop control variable.

      Make a for-loop that reads/copies the key, 
      one character at a time into the array.
   */
}

void doGrading(char key[], ifstream & infile)
{
   /*
      Declare a variables to represent the number of tests to grade.

      Read/copy the value of the integer (number of tests) 
                into the variable.   

      Declare a variable to use to control a for-loop.

      Make a for-loop that calls gradeOneTest for each test.

      Finish by printing any blank lines that may be needed for the display.

   */
}

void gradeOneTest (int studentNum, char key[], ifstream & infile)
{
   /*
      Declare int numCorrect to represent the number of correct answers.

      Initialize numCorrect to 20.
  
      Declare a variable int questionNum to control a for-loop.

      Declare a variable char theAnswer for storing one test answer at a time.

      Make a for-loop that reads 20 answers.  
      Each time through the for-loop, read one answer into theAnswer,
      and execute an if-statement:  
      If theAnswer is not equal to key[questionNum]
      then subtract 1 from numCorrect.

      After the end of the for-loop, place code that writes studentNum 
      and numCorrect on the screen in the appropriate locations.
      If numCorrect is 12 or more, write "PASS" else write "FAIL".
      In the code that puts the results on the screen, 
      Use setw() manipulators to make the columns line up.
   */
}