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

App we were taught on is visual studio 2015 using the format #include <iostream>

ID: 3854636 • Letter: A

Question

App we were taught on is visual studio 2015 using the format
#include <iostream> using namespace std; int main() {
system("pause"); return o; }
Please make it as simple as possible so I can follow it, I actually learn a lot from what you guys show me. Thank you in advance The local Driver's License Office has asked you to write a program that grades the writ ten portion of the driver's license exam. The exam has 20 multiple choice questions Here are the correct answers: 1. A 2. D 3. B 4. B 5. C 6. B 7. A 8. B 9. C 10. D 16. C 12. C 13. D 14. B 15. D 18. A 19. D 20. B Your program should store the correct answers shown above in an array. It should ask the user to enter the student's answers for each of the 20 questions, and the answers should be stored in another array. After the student's answers have been entered, 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. Input Validation: Only accept the letters A, B, C, or D as answers. Please do not declare any arrays as globals. If you have questions, please either ask you team members or put on discussion board for answers. Submit online.

Explanation / Answer

// Driver’s License Exm - Check user's answers

#include<iostream>

#include <cctype>

// Required for toupper

using namespace std;

// Function prototypes

void input(char [], int);

void checkAnswers(char[], char[], int &, int &, int);

int main()

{

// Constant for the number of questions

const int ARRAY_SIZE = 20;

// Array of the correct answers

char answers[ARRAY_SIZE] = { 'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A' };

// Array to hold the student's replies

char replies[ARRAY_SIZE];

// Accumulator for number of correct answers

int correctAnswers = 0;

// Accumulator for number of incorrect answers

int incorrectAnswers = 0;

// Get the student's replies for each question.

input(replies, ARRAY_SIZE);

// Check the student's replies against the correct answers.

checkAnswers(answers, replies, correctAnswers, incorrectAnswers, ARRAY_SIZE);

// Determine whether the student passed or failed.

if (correctAnswers > 14)

cout << " The student passed the exm. ";

else

cout << " The student failed the exm. ";

// Display the numbers of correct and incorrect

// answers provided by the student.

cout << "Correct Answers: " << correctAnswers << endl;

cout << "Incorrect Answers: " << incorrectAnswers << endl << endl;

// Display a list of the questions that were

// incorrectly answered.

cout << "Questions that were answered incorrectly: ";

for (int i = 0; i < 20; i++)

if (answers[i] != replies[i])

cout << (i + 1) << endl;

//system("pause");

return 0;

}

// ********************************************************

// The input function accepts an array of characters and *

// an integer for the size of the array. The function *

// asks the user to input answers to the exm and stores *

// them in the array. *

// ********************************************************

void input(char array[], int size)

{

for (int i=0; i < size; i++)

{

cout<<"Answer #"<<i+1<<": ";

cin>>array[i];

if(array[i] < 'A' || array[i] > 'D')

{

cout<<"Invalid answer. Try again. ";

i--;

}

}

}

// ********************************************************

// The checkAnswers function compares the values in the *

// answers array to the values in the replies array. The *

// number of correct and incorrect answers are stored in *

// the correct and incorrect reference parameters. *

// ********************************************************

void checkAnswers(char answer[], char replies[], int &correct, int &incorrect, int size)

{

for(int i = 0; i < size; i++)

if(answer[i] == replies[i])

correct++;

else

incorrect++;

}

If you need any refinements, just get back to me.

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