//Xinnuo Wang                   CS1A                            chapter7 #9
/*******************************************************************************
 * Grade an Exam
 * _____________________________________________________________________________
 * The program accepts 20 answers,grades the written portion of the exam and 
 * displays the total number of correctly answered questions, the total number 
 * of incorrectly answered questions, and a list showing the question numbers of 
 * the incorrectly answered questions.
 * 
 * _____________________________________________________________________________
 * Input:
 *    choice      : The accepted choices in an array.
 *    solution    : The solutions in an array.
 * Output:
 *    c_num       : The total number of correctly answered questions.
 *    ic_num      : The total number of incorrectly answered questions.
 * 
 * ****************************************************************************/
#include <iostream>
using namespace std;

int main() {
	const int SIZE = 20;
	char choice[SIZE];
	char solution[SIZE] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'};
	int c_num = 0;
	int ic_num = 0;
	int m= 0;
	int ic_choice[20];
	for(int i = 0; i < SIZE; i++)
	{
		cout << "Enter your answer of qustion " << i+1 ;
		cin>> choice[i];
		cout << choice[i] << endl;
		// validate check
		while(choice[i]!= 'A'&&choice[i]!= 'B'&&choice[i]!= 'C'&&choice[i]!= 'D')
		{
			return 0;
		}
		if(choice[i] == solution[i])
		{
			c_num ++;
		}
		else 
		{
			ic_num ++;
			ic_choice[m]=i+1;
			m++;
		}
	}
	// Output Result
	if (c_num >=15)
	{
		cout<< "You pass the exam!"<< endl;
	}
	
	cout << "The total number of correctly answered questions is: " << c_num << endl;
	cout << "the total number of incorrectly answered questions is : " << ic_num << endl;
	cout << "A list showing the question of the incorrectly answered questions";

	for (int n = 0; n< ic_num ; n++)
	{
		cout<< ic_choice[n]<< " " ;
	}
	return 0;
}