grading program

Im so confused. ive been working on this program for a long time but I still am clueless. Please any help or advice would be great. I dont wanna make it seem like im passing of my work but at this point im so confused. I thought some help would be useful. Thanks in advance


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <fstream>
#include <iostream>
#include <iomanip>
#include <assert.h> 

using namespace std ;

void makeRepTitles() ;
void getKey (char key[], ifstream & infile) ;
void doGrading(char key[], ifstream & infile) ;
void gradeOneTest (int studentNum, char key[], ifstream & infile) ;

int main(void) 
{ 
/*
The main steps in this program could be:
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.
Close the input file.
*/
ifstream infile("testData") ; 

getKey (key[], ifstream & infile) ;
makeRepTitles() ;
doGrading(key[], ifstream & infile) ;



return 0;
} 

void makeRepTitles()
{
/* This could be a function that puts the following on the screen: 
Student Number Number Correct PASS/FAIL
(put the appropriate number of blank lines before and after.) */
cout << endl ;
cout << "Student Number Number Correct PASS/FAIL" ;
cout << endl 
<< endl ;}

void getKey (char key[], ifstream & infile)
{
/* In this function, you could declare a loop control variable, and make a
for-loop that reads/copies the key, one character at a time into the
array. */ 
for( int count = 0; count < key.length(); count++)
{
if( answers[count] == key[count] )
grade++;
else
outData << " b b c b c d d c a d a d e c b e a d e b " ;
}
}

void doGrading(char key[], ifstream & infile)
{
/* In this function you could:
* Declare a variable to represent the number of tests to grade.

* Read/copy the value of the integer (number of tests) 
from the input file stream 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.
*/
char gradestest ;
cin >> gradestest ;
}

void gradeOneTest (int studentNum, char key[], ifstream & infile)
{
/* Steps that would work here:

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, it reads one answer into 
this variable: theAnswer,
and executes 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.
After that, 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.
*/
}


its supposed to look like this

Student Number      Number Correct       PASS/FAIL

       1                  4                FAIL
       2                  5                FAIL
       3                 13                PASS
       4                 10                PASS
       5                 14                PASS
Last edited on
Where exactly are you having problems? Your comments seem to tell you almost exactly what to do so I'm not what the problem is exactly?
sorry im an idiot. Im confused on the gradeonetest function, i dont completely get how to set up the for loop
Topic archived. No new replies allowed.