Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this one! This is what should look like: The local Driver's License Office has asked you to write a program that

Please help me with this one!

This is what should look like:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
The local Driver's License Office has asked you to write a program that grades the written portion of the drivers license exam. The exam has 20 multiple choice questions, each with letter answers from 'A' to 'D'. Make sure to only allow input values of 'A' - 'D'. Your program should store the correct answers in the text file in an array. It should then ask the user to type in the students answers for each of the 20 questions, and the answers should be stored in a second array. After the students answers have been entered, the program should display a message indicating if the person passed or failed the exam, given that it takes 15 or more correct answers to get a passing grade. You will want to save the in the same directory as the cpp file that you are using. To be clear: 1. Open the file Data. and read the 20 character values into an array. 2. Close the data file. 3. Ask the user for their 20 answers to questions 1-20. 1. Make sure each answer is between 'A' and 'D' 2. While the array uses 0 - 19, make sure the questions ask for 1 - 20. 4. Compare the two arrays to see how many match. 1. Use a function for this. 2. The function Declaration should be int scoreExam(char key, char answers, int size). 5. Tell the user whether they passed or failed depending on if they got 15 or more correct.cout > answer; studentans [1] = answer; score = scoreExam (correctans [size], studentans [size], size); // Funtion Hint scoreExam (char key , char answers , int size) int i = 0, correctanswers = 0; for (i = 0; i > correctans[i]; datafile.close(); // Ask for students' answers for (i = 0; i > answer; while (answer != 'A' && answer != 'B' && answer != 'C' && answer != 'D' ) { cout > answer; studentans [i] = answer; score = scoreExam(correctans [size], studen Studentans [size], size);#include #include #include using namespace std; // Prototype int scoreExam(char key, char answers, int size); lint main() const int size = 20; const int correctneed = 15; int i = 0, score; char correctans [size], studentans [size], answer; // Open the file and take out the data ifstream datafile: datafile. open( .nata "); if (!datafile) cout > correctans[i]; datafile.close(); // Ask for students' answers for (i = 0; i > answer; while (answer != 'A' & answer != 'B' && answer != 'C' && answer != 'D') cout >

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

10. What is a contractual cash flow?

Answered: 1 week ago