subject

The assignment: Write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice questions (answers input into code already.
Your program should store the student's answers for each of 20 questions in an array, the answers 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). It should 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 A, B, C or D as answers.
Here's my code:
#include
using namespace std;
/* This Driver's License Exam program will grade the written portion of the driver's license exam.
The program will store the correct answers to 20 multiple choice questions and once the student answers
have been entered, grade the exam. */
int main()
{
// Define variables
int count, // counter variable for loops
correct=0, // variable to count the number of correct answers input by student
inCorrect=0; // stores the amount of incorrectly answered questions
const int size = 20; // constant variable for max size (there will be 20 spots in array)
char studentAnsw[size]; // studentAnsw array stores student input
// store answers to multiple choice questions in storedCorrectAnswer array
char storedCorrectAnsw[size] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D',
'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'};
// Allow student to input answers, store in studentAnsw Array
cout << "Please enter your answers to the multiple choice questions by inputting A, B, C, or D. Upper case only." << endl;
// if statement for input validation to go into loop must be A B C or D
if(studentAnsw[size]!='A'||'B'||'C' ||'D')
{
cout << "Please input A, B, C or D for your answer, all upper case." << endl;
cin >> studentAnsw[size];
}

if(studentAnsw[size]=='A'||'B'||'C' ||'D')
{
// for loop to match storedCorrectAnswer array against studentAnswer array and tally correct answers
for (count=0; count<=size-1; count++)
{
cout << "Enter the answer for Question " << (count+1) << ": ";
cin >> studentAnsw[count];
}

if (storedCorrectAnsw[count] == studentAnsw[count])
correct+=1;

if (storedCorrectAnsw[count] != studentAnsw[count])
inCorrect+=1;
}
// Display whether student passed of failed.
if(correct>=15)
{
cout << "Congratulations! You passed the Driver's Exam with " << correct << " out of 20 questions correct." << endl;
}
else
{
cout << "Unfortunately you did not pass the exam. You only had " << correct << " out of 20 questions correct." << endl;
}
// pause
system("pause");
return 0;
}
I'm having 3 problems
1) I have a validation statement to ensure that A, B, C, or D is entered but it is not working.
2) I have entered the information into the storedCorrectAnsw array. I have done a for loop to get input into a 2nd array called studentAnsw... this is working fine, getting and storing input. I can output at the end passing of failing test, along with how many questions were correct out of 20. The problem is I can't figure out how to compare the studentAnsw array with the storedCorrectAnsw array and return only the question numbers that were wrong?

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:20
Which of these is a benefit of social networking? oa. hiding your true identity from friendsob. avoiding talking to people in personoc. spending time with friends instead of studyingod. connecting with new people
Answers: 2
question
Computers and Technology, 23.06.2019 16:30
You have read about the beginnings of the internet and how it was created. what was the internet originally created to do? (select all that apply) share research. play games. communicate. share documents. sell toys
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
The footer area of a web page generally houses which website feature? terms of use web page content business name or title menu headings
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
You know the right answer?
The assignment: Write a program that grades the written portion of the driver's license exam. The ex...
Questions
question
Mathematics, 17.12.2019 21:31
question
English, 17.12.2019 21:31
question
History, 17.12.2019 21:31
question
History, 17.12.2019 21:31
Questions on the website: 13722367