Computers and Technology
Computers and Technology, 22.05.2020 19:00, simbupls

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?

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 09:20, lovely222
How to print: number is equal to: 1 and it is odd number number is equal to: 2 and it is even number number is equal to: 3 and it is odd number number is equal to: 4 and it is even number in the console using java using 1 if statement, 1 while loop, 1 else loop also using % to check odds and evens
Answers: 3
image
Computers and Technology, 23.06.2019 20:30, lucywood2024
What is the biggest difference between section breaks and regular page breaks
Answers: 1
image
Computers and Technology, 24.06.2019 00:10, roxymiller3942
Read each statement below. if the statement describes a peer-to-peer network, put a p next to it. if the statement describes a server-based network, put an s next to it. p - peer-to-peer s - server-based
Answers: 1
image
Computers and Technology, 24.06.2019 01:30, BIKRAMlawati5544
Could you find out how im still getting an 83 percent on this in edhesive a = input("enter an animal: ") s = input ("enter a sound: ") e = "e-i-e-i-o" print ("old macdonald had a farm, " + e) print ("and on his farm he had a " + a + "," + e) print ("with a " + s + "-" + s + " here and a " + s + "-" + s + " there") print ("here a " + s+ " there a " + s) print ("everywhere a " + s + "-" + s ) print ("old macdonald had a farm, " + e)
Answers: 2
Do you know the correct answer?
The assignment: Write a program that grades the written portion of the driver's license exam. The ex...

Questions in other subjects:

Konu
Social Studies, 10.02.2020 19:20