I need this in a step by step C# program language. The local driver\'s license o
ID: 3867776 • Letter: I
Question
I need this in a step by step C# program language.
The local driver's license office has asked you to create an application that grades the written portion of the driver's license exam. The exam has 20 multiple-choice questions. Here are the correct answers: Your program should store these correct answers in an array. The program should read the student's answers for each of the 20 questions from a text file and store the answers in another array. (Create your own text file to test the application.) After the student's answers have been read from the file, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display 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.Explanation / Answer
#include <iostream>
#include <conio.h>
#include <cctype>
using namespace std;
void input(char[], int);
void checkAnswers(char[], char[], int&, int&, int);
int main()
{
const int NUM_QUESTIONS = 20; //Constant for the number of questions
char answers[NUM_QUESTIONS] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'};
char replies[NUM_QUESTIONS];
int correctAnswers = 0;
int incorrectAnswers = 0;
input (replies, NUM_QUESTIONS);
checkAnswers(answers, replies, correctAnswers, incorrectAnswers,
NUM_QUESTIONS);
if (correctAnswers > 14)
cout << " Student passed the exam ";
else
cout <<" Student failed the exam ";
cout << "Correct Answers = " << correctAnswers << endl;
cout << "Incorrect Answers = " << incorrectAnswers << endl;
cout << "The list below shows the question numbers of the incorrectly";
cout << " answered questions. ";
for (int i =; i < 21; i++)
{
if (answers[i] != replies[i])
{
cout << (i + 1) << endl;
}
}
_getch();
return 0;
}
void input(char input[], int NUM_QUESTIONS)
{
char input1;
cout << "Enter your answer";
cin >> input1;
for (char input1 = 0; input1 < NUM_QUESTIONS; input1++)
while (input1 !='A'&& input1 != 'B'&& input1 != 'C' && input1 != 'D');
{
cout << "You must enter A, B, C, or D ";
cin >> input1;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.