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, 22.06.2019 10:30, dreyes439
You are almost finished updating a web site. as part of the update, you have converted all pages from html 4.0 to html5. the project is currently on schedule. however, your project manager has been asked by the marketing team manager to justify a day of time spent validating the site's html5 pages. the marketing team manager does not have technical knowledge of the internet or the web. which is the most appropriate explanation to provide to the marketing team manager?
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, amberpublow7
Which best describes the role or restriction enzymes in the analysis of edna a. to break dna into fragments that vary in size so they can be sorted and analyzed b. to amplify small amounts of dna and generate large amounts of dna for analysis c. to purify samples of dna obtained from the environment so they can be analyzed d. to sort different sizes of dna fragments into a banding pattern that can be analyzed
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, kp2078
What type of slide show is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer? a. ole b. photo album c. brochure d. office clipboard
Answers: 2
image
Computers and Technology, 23.06.2019 13:30, powellmj9216
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
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
History, 04.09.2019 22:30