Question: This assignment will exercise the use of OOP classes, accessor function, mutator functions, and arrays of objects. Write a program quiz generator program to help

This assignment will exercise the use of OOP classes, accessor function, mutator functions, and arrays of objects.

Write a program quiz generator program to help students study for quizzes and exams. The program must call a function that reads a set of multiple choice questions from a file, storing the questions in an array of object of the class Question. The class maintains the question text, an array of possible answers, and the correct answer.

After loading the questions, the program should loop through the array prompting the student with the question and checking the students answer. The program should indicate correct to the student, if the answer is correct, otherwise indicate incorrect and display the correct answer (see sample) below.

After all questions have been answered, the program should display the student score in points, and correct score percentage.

The question file format is as follows:

(1) question text?

first possible answer

second possible answer

third possible answer

fourth possible answer

fifth possible answer

x correct answer number.

(2) question text?

first possible answer

second possible answer

third possible answer

fourth possible answer

fifth possible answer

x correct answer number.

(n) question text?

first possible answer

second possible answer

third possible answer

fourth possible answer

fifth possible answer

x correct answer number.

Name your program lastNamePass4.cpp. Your program should meet the following requirements

main()

  1. Declare variables and Question array. Use a constant for the number_of_questions.
  2. Call initQuestions() function to load array with questions.
  3. Use a loop to prompt student with question and read answer.
    1. Call displayQuestion to display question.
    2. use cin >> ans to read student answer.
    3. If the answer is correct, display correct
    4. Else display incorrect and then display the correct answer.
    5. Increment array index and repeat loop until all questions
  4. After all questions have been issues, display student results.

initQuestions()

  1. Define a function (initQuestions()) that implements the following logic:
    1. Opens questions.txt and checks for a valid open issues error and exits if not successful.
    2. Uses a while loop to read the question text, five answers, and the correct answer number. Use setter methods to store the questions in a Question object array. Be certain to protect against data overrunning the array.

displayQuestion()

  1. Define a function (displayQuestion())) that displays the question text and possible answers. (See sample run for format).

Question Class

  1. Define a class called Question in its own header file Question.h. Be certain to create an include guard.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!