Question: The following program must be written in C++. No pointers are allowed. questions.txt Placement_In_Race You are third place right now in a race. What place
The following program must be written in C++.
No pointers are allowed.





questions.txt
Placement_In_Race You are third place right now in a race. What place are you in when you pass the person in second place? 1st 2nd 3rd None of the above 2nd 0 1
Days_In_Month How many months have 28 days? 2 1 All of them. Depends if there's a leap year or not. All of them. 0 1
Dead_Sheep A farmer has 17 sheep, all of them but 8 die. How many sheep are still standing? 8 9 25 35 8 1 1
Popeye Which of the following gives Popeye his strength? Broccoli Spinach Fried chicken All of them. Spinach 1 1
Arithmetic_Expressions If x is 5, what is the value of y after the statement y = x + 10; is executed? There is no result due to a compilation error. 15 5 This is an invalid statement. 15 1 2
What_Am_I I am tall when I am young and I am short when I am old. What am I? Person Candle Giraffe None of the above Candle 1 1
Yellow There is a one-story house in which everything is yellow. Yellow walls, yellow doors, yellow furniture. What color are the stairs? Yellow White There are no stairs it is a one-story house Concrete There are no stairs it is a one-story house 0 1
Hair_on_Head A man who was outside in the rain without an umbrella or hat did not get a single hair on his head wet. Why? He was bald. He was under a roof. He was too short. None of the above. He was bald. 0 1
Lucky_Seven I am an odd number. Take away a letter and I become even. What number am I? Eleven Seven Five There is no such number. Seven 1 1
Handle_With_Care What is so fragile that saying its name breaks it? Glass Air Silence None of the above. Silence 0 1
Eating_Apples Five people were eating apples, A finished before B, but behind C. D finished before E, but behind B. What was the finishing order? ABCDE EDBCA CABDE CABED CABDE 1 1
Catching_Mice If five cats can catch five mice in five minutes, how long will it take one cat to catch one mouse? 1 minute 5 minutes 25 minutes 15 minutes 5 minutes 1 1
Wrong_Way A truck driver was going down a one-way street the wrong way. There were two policemen on duty along the street yet they didn't stop him. Why? He was their friend. They were on strike. The truck driver was walking. There were no vehicles coming the other way. The truck driver was walking. 1 1
END
This assignment requires you to write a program to generate a multiple-choice exam. The file, questions.txt, contains a set of multiple-choice questions. Each question has exactly four responses. The following shows the layout of each item of data that is stored for a question: Data Item Description Question ID (a string without spaces on a line by itself) The actual question on a line by itself (a string that could contain spaces) Responses Four responses, each on a line by itself, followed by the correct response on a line by itself, followed by 1 or 0 where 1 indicates that the responses should be shuffled and indicates otherwise. Points The amount of points gained if the question is correctly answered. For example, here is the data for one of the questions in questions.txt: ID Text Data Popeye Which of the following gives Popeye his strength? Broccoli Spinach Fried chicken All of them. Spinach 1 1 Description ID of question Question text Choice 1 Choice 2 Choice 3 Choice 4 Correct answer 1: shuffle responses; O: don't shuffle If correctly answered, 1 mark is awarded Program Requirements Your program must provide the following functionality: (a) Read all the questions from the file, questions.txt, and store them in an array. This array is referred to as the Question Bank. The file contains no more than 100 questions. (b) Create an array of exam questions by randomly selecting questions (specified by the user) from the Question Bank. The array of exam questions is referred to as the Exam. When a question is selected from the Question Bank, the four responses must be shuffled, if necessary. (c) Allow a user to take the exam by presenting the questions from the exam, one by one. Three actions are possible when a question is displayed to the user: () the user answers the question correctly (ii) the user answers the question incorrectly the user skips the question A record must be kept of the user's performance on each question. (d) At the end of the examination, a summary of the user's performance is given. The summary displays how many responses were correct or incorrect and how many questions were skipped. The total marks obtained by the user is also displayed. Structs You should use the structs in Table 1 in your code: Description Contains the four responses for a question, the correct answer, and a variable indicating whether the responses should be shuffled after they are selected for an examination. Struct struct Responses string text[4]; string answer, bool shuffle; }; struct Question { string ID; string text; Responses responses int points; Contains the ID of a question, the text of the question, a struct of Responses, and the amount of points that are gained by answering the question correctly. struct Summary { string questionID; bool correct; bool skipped; string answer, string given Answer; int points; }; Contains the ID of a question attempted by the user, whether it was skipped or correctly answered by the user, and the amount of points obtained. If it was not skipped, stores the correct answer and the answer given by the user. Table 1: Structs to be Used in Assignment 1 int readQuestions (Question questionBank []) This function reads all the questions from questions.txt into the Question Bank. It returns the amount of questions in the Question Bank. bool containsQuestion (Question exam[], int numExamQuestions, string questionID) Returns true if the exam already contains the question with the given question and false, otherwise. bool contains Response (Responses responses, int numResponses, string response) Returns true if the set of responses already contains the given response, and false otherwise. 1 Question shuffleResponses (Question question) This function takes the question passed as a parameter, shuffles the responses if the responses can be shuffled, and returns the modified question. void prepareExam (Question questionBank[], int numQuestions, Question exam[], int numExamQuestions) Creates the exam containing numExam Questions where the questions are taken from the Question Bank which contains numQuestions. void displayexamQuestion (Question question) While the exam is in progress, displays a question for the user to answer. void generateExam Question exam[], int numExamQuestions, Summary summary[]) After the exam is generated, presents the questions on the exam to the user, one by one. Takes a note of how the user responded to each question, for the summary at the end. void displaySummary (Summary summary[], int numExamQuestions) Displays a summary of the user's performance on each question of the exam, after the exam is completed. int main() Calls readQuestions, prepare Exam, generateExam, and displaySummary. Selecting a Question from the Question Bank at Random Suppose there are N questions in the Question Bank and the exam must have M questions where M
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
