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
|
#include<iostream>
#include<string>
using namespace std;
class TestGrade
{
public: void setKey(char []);
void grade(char []);
char canswers[20];
}
void TestGrade::setKey(char answers[])
{
for(int index = 0; index < 20; index++)
{
canswers[index] = answers[index];
}
}
int main()
{
const char SIZE = 20;
char answer[SIZE];
char answers[20] = {'B', 'D', 'A', 'A',
'C', 'A', 'B', 'A',
'C', 'D', 'B', 'C',
'C', 'B', 'D', 'A'};
cout << "Welcome to the written portion of the DMV exam. \n";
cout << "You may only enter capital A, B, C, or D for your answers.\n\n" << endl;
for (int index = 0; index < SIZE; index++)
{
cout << "Enter your answer for question " << index+1 << endl;
cin >> answer[index];
while (answer[index] != 'A'
&& answer[index] != 'B'
&& answer[index] != 'C'
&& answer[index] != 'D')
{
cout << "ERROR: you must input capital A,B,C, or D" << endl;
cin >> answer[index];
}
}
system("pause");
return 0;
}
|