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: 3858336 • 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 UMLOnce 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 <string>

#include <fstream>

class test_questions

{

private:

               int score;

               int numberofQuestions;

               int numberofAnswers;

               std::string questionType;

               int questionValue;

               std::string question;

               std::string mcAnswers[10];

               std::string answer;

               std::fstream testData;

               bool opentest(std::string);

               void closetest();

               void dotest();

public:

               test_questions();

               bool Run(std::string);

};

test_questions::test_questions()

{

               score = 0;

}

bool test_questions::opentest(std::string Test)/* functions opens the file*/

{

               testData.open(Test, std::ios::in);

               if (testData.fail())

                               return false;

               return true;

}

void test_questions::closetest() /*functions closes the file test */

{

               testData.close();

}

void test_questions::dotest() /*performs the operations here*/

{

               std::string data;

               std::string qData; /*question data*

               std::string aData; /*answer data */

               std::string mcData;   /*multiple choice data here */

               getline(testData, data);

               numberofQuestions = stoi(data);

bool test_questions::Run(std::string Test)

{

               if (opentest(Test)) {

                               doQuestions();

                               closetest();

               }

               else

                               return false;

               return true;

}

int _tmain(int argc, _TCHAR* argv[])

{

               test_questions Game;

               if (!Game.Run("Test.txt"))

                               std::cout << "test doest begin if there is no data in the test file.";

               system("pause");

               return 0;

}

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