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
|
int main()
{
const int size = 20; // Array size
char answers[size] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D',
'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'},
studentAnswers[size];// Holds the line of user input
int count = 0;
int sCount = 0;
int incorrect = 0;
bool space = true;
for (count = 0; count < size; count++)
{
if (!space) // extra code to help with spacing
{
cout << "\n";
}
cout << "What is your score for test " << (count + 1) << " ? ";
cin >> studentAnswers[count];
while ((studentAnswers[count] != 'A' && studentAnswers[count] != 'B' &&
studentAnswers[count] != 'C' && studentAnswers[count] != 'D'))
{
cout << "You must enter A, B, C, or D. ";
cin >> studentAnswers[count];
space = false;
}
}
processAnswers(studentAnswers, answers, size);
system("pause");
return 0;
}
|