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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:40, melaniem50
Curriculum exam to process a resident's payment, you must click on onesite payments home page. from the a. reports b. my settings o c. transactions o d. rent tab
Answers: 1
image
Computers and Technology, 23.06.2019 19:30, 123iamthe1
You can apply several different worksheet themes from which tab?
Answers: 1
image
Computers and Technology, 24.06.2019 13:20, sanaiajohnson56
In the insert table dialog box, you select the checkbox to create the first row as the header of the table.
Answers: 3
image
Computers and Technology, 24.06.2019 21:30, moonk7733
The hybrid uses 144 to 158 volt batteries.
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 in other subjects:

Konu
Mathematics, 14.09.2020 05:01
Konu
Mathematics, 14.09.2020 05:01
Konu
Mathematics, 14.09.2020 05:01
Konu
Mathematics, 14.09.2020 06:01
Konu
Mathematics, 14.09.2020 06:01
Konu
Mathematics, 14.09.2020 06:01
Konu
Mathematics, 14.09.2020 06:01
Konu
Social Studies, 14.09.2020 06:01
Konu
Mathematics, 14.09.2020 06:01