Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to read in various types of test questions (multiple choice

ID: 3858357 • Letter: W

Question

Write a C++ program to read in various types of test questions (multiple choice and True/False) from a test bank (text file), and load the questions into an array of questions. You will need to implement the following class hierarchy (given in UML): Once the test bank has been loaded, simply iterate over the array of questions and have each question printed out to the screen. The test bank (text file) will have the following format: Line 1 will be an integer value, indicating how many questions in the file. Each question will start with a line that starts with either "MC" or "TF" followed by a space and then the point value of the question. The next line will be the actual question. If the question was True/False, the following line will be the answer, either "True" or "False". If the question was multiple choice, the following line will be an integer value indicating how many choices will be provided for that question. The following lines will be the choices. There will never be more than 6 choices. The final line following the choices will be the answer: "A" or "B" or "C" or "D" or "E" or "F".

Explanation / Answer

#include<iostream>

#include<fstream>

#include<string>

using namespace std;

class Question

{

public:

string QuestionName[2000];

string Answer[2];

string Status[2];

const int size=2;

int debug=size;

ifstream infile;

int i=0;

void WriteData()

{

infile.open("input.txt");

cout<<"Enter All Status ";

for(int j=0;j<2;j++)

{

cin>>Status[j];

infile>>Status[j];

}

cout<<" Enter All QuestionS ";

for(int j=0;j<2;j++)

{

cin>>QuestionName[j];

infile>>QuestionName[j];

}

cout<<" Enter the Correspoinding Answers To the Questions T->True F->False A B C D E F ";

for(int j=0;j<2;j++)

{

  

  

cin>>Answer[j];

infile>>Answer[j];

}

}

  

void DisplayData()

{

for(int i=0;i<size;i++)

{

cout<<"Status is "<<Status[i];

cout<<" Question Name "<<QuestionName[i];

cout<<" Answer is "<<Answer[i];

cout<<" ";

}

  

}

};

int main()

{

Question obj;

obj.WriteData();

obj.DisplayData();

return 0;

}

Output:

Enter All Status

MC

TF

Enter All QuestionS

PleaseChooseAmong6

True

Enter the Correspoinding Answers To the Questions T->True F->False A B C D E F

A

T

Status is MC Question Name PleaseChooseAmong6 Answer is A

Status is TF Question Name True Answer is T

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote