-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleApplication8.cpp
More file actions
78 lines (68 loc) · 2.96 KB
/
Copy pathConsoleApplication8.cpp
File metadata and controls
78 lines (68 loc) · 2.96 KB
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
// ConsoleApplication2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int checkAnswers(char[], char[], int);
char getInput();
int main()
{
char answers[] = { 'B','A','B','C','D','A', 'D', 'B', 'B', 'C', 'C', 'C', 'A', 'D', 'B', 'A', 'C', 'D', 'B', 'D' };
const int SIZE = 20;
char testAnswers[SIZE];
int correct = 0;
int incorrect = 0;
int corrections[SIZE];
for (int i = 0; i < SIZE; i++)
{
testAnswers[i] = getInput();
}
for (int j = 0; j < SIZE; j++)
{
double check=checkAnswers(testAnswers,answers,j);
if (check == 1)
{
correct++;
corrections[j] = 99;
}
else if (check == 0)
{
incorrect++;
corrections[j] = j+1;
}
}
cout << "The number of correct answers is " << correct << endl;
cout << "The number of incorrect answers is " << incorrect << endl;
for(int k=0;k<SIZE;k++)
{
if (corrections[k]!= 99)
{
cout << corrections[k] << endl;
}
}
cin.ignore();
return 0;
}
int checkAnswers(char answers[],char testAnswers[],int index)
{
char check1 = answers[index];
char check2 = testAnswers[index];
if (check1 == check2)
{
return 1;
}
else
{
return 0;
}
}
char getInput()
{
char answer;
do {
cout << "Please enter an answer, Mr. Bond." << endl;
cin >> answer;
} while (answer != 'A'&&answer != 'B'&&answer != 'C'&&answer != 'D');
return answer;
}