This is what the question.txt file format is supposed to look like
(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.
This program I'm doing is supposed to be a quiz program. 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 student’s answer. The program should indicate “correct” to the student, if the answer is correct, otherwise indicate “incorrect” and display the correct answer.
After all questions have been answered, the program should display the student score in points, and correct score percentage.
This is the int main function I thought I could walk through this one?
int main()
⦁ Declare variables and Question array. Use a constant for the number_of_questions.
1 2 3
|
int ans;
const int num_of_questions = 5;
string questions[num_of_questions];
|
⦁ Call initQuestions() function to load array with questions.
|
initQuestions(questions, num_of_questions);
|
⦁ Use a loop to prompt student with question and read answer.
(Don't know how to do this. I know I should though. I'm trying to run before I can walk basically.)
⦁ Call displayQuestion to display question.
⦁ use cin >> ans to read student answer.
⦁ If the answer is correct, display correct
1 2 3
|
if(ans == correctAnswer){
cout << "Correct!" << endl;
}
|
⦁ Else display incorrect and then display the correct answer.
1 2 3
|
else{
cout << "Incorrect." << endl;
}
|
⦁ Increment array index and repeat loop until all questions
⦁ After all questions have been issues, display student results.
1 2 3
|
cout << "Drill over. Here are the points: " << endl;
cout << "Student Score in points: " << endl;
cout << "Student correct score percentage: " << endl;
|
That's what I have so far. I know I have a lot of missing parts and fill in the blank areas.