Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Needs to be answered in c#, windows form application please insert a screenshot

ID: 3779801 • Letter: N

Question

Needs to be answered in c#, windows form application

please insert a screenshot of the outcome! thank you!

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

Please follow the code and comments fo rdescription :

CODE :

#include <iostream> // required header files
#include <fstream>
#include <cstring>

using namespace std;

int main () { // driver method
   string line; // local variables
   ifstream myfile ("answers.txt");
   char data[1024];
   int wrong[20];
   int count = 0, m = 0;
   char correct[] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'}; // correct array
   if (myfile.is_open()) // open the file
   {
       while ( getline (myfile,line) ) { // iterate over the data
           strncpy(data, line.c_str(), sizeof(data)); // copy the file data to a array
           data[sizeof(data) - 1] = 0; // set the other data to 0
       }
       for(int i = 0; i < 20; i++) { // iterate to check for the data equal
           if(correct[i] == data[i]) {
               count++; // increment the count
           } else {
               wrong[m] = (i + 1); // add the list to the array
               m++;
           }
       }
       cout << "The Correct Answers Count is : " << count << endl; // print the data to console
       cout << "The Incorrect Answers Count is : " << (20 - count) << endl;
       cout << "The Wrong Question Numbers are : " << endl;
       for(int j = 0; j < 20; j++) {          
           cout << wrong[j] << endl; // message
       }
       myfile.close(); // close the file
   } else {
       cout << "Unable to open file"; // message
   }
   return 0;
}

OUTPUT :

The Correct Answers Count is : 14
The Incorrect Answers Count is : 6
The Wrong Question Numbers are :
9
10
12
13
19
20

answers.txt :

BDAACABADCBDCADCCBAD


Hope this is helpful.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote