Question: C++ help to make Multiple choice function for testbank file I/O program. I made the function I just need help figuring out how to do

C++ help to make Multiple choice function for testbank file I/O program. I made the function I just need help figuring out how to do the choices for it. Below is my code and the pseudo code to assist.

Pseudocode:

If MC question, then

i. Ask how many points the question worth.

ii. Enter the question. iii. Ask home many options, say OP

iv. Loop 1 to OP

1a. Enter the option.

2a. Repeat step iv until reaches value OP

v. Enter the answer to the question.

The output stored in the file for the MC should look like this example (I did not include the TF this is only selecting MC what it should look like):

MC 10 Who was the President of the USA in 1991? 6 Richard Nixon Gerald Ford Jimmy Carter Ronald Reagan George Bush Sr. Bill Clinton E

My code:

#include "stdafx.h"

#include

#include

#include

using namespace std;

class TestBank

{

public:

void TrueFalse(ofstream&);

void MultipleChoice(ofstream&);

};

int main()

{

TestBank bankObj;

ofstream test;

int testNumber, typeOfQuestion;

char yesOrNo;

// Create test bank file.

test.open("C:\\temp\\testBankFile.txt");

if (test.is_open())

{

cout

cin >> testNumber;

test

int nextNum = 1;

//create the test bank

for (int i = testNumber; i > 0; --i)

{

cout

cin >> typeOfQuestion;

if (typeOfQuestion == 1)

test

else if (typeOfQuestion == 2)

test

else

cout

switch (typeOfQuestion)

{

case 1: bankObj.TrueFalse(test);

break;

case 2: bankObj.MultipleChoice(test);

}

}

test.close();

}

else

{

cout

}

system("pause");

return 0;

}

// function to create true/false question

void TestBank::TrueFalse(ofstream& thefile)

{

int points;

string question;

string answer;

char yn;

do

{

cout

cin >> points;

cin.ignore();

cout

getline(cin, question);

cout

cin >> answer;

cin.ignore();

cout ? ";

cin >> yn;

} while (yn == 'y');

//Write all information into the file

thefile

thefile

thefile

}

//Now you have to complete function MultipleChoice()

// function to create multiple choice question

void TestBank::MultipleChoice(ofstream& theFile)

{

}

I also need to make the program read in the file after all information is collected to display out the collected information from the file. The result should look like this:

C++ help to make Multiple choice function for testbank file I/O program.

This means the output file would look like this:

3 TF 5 There exists birds that cannot fly? true MC 10 Who was the President of the USA in 1991? 6 Richard Nixon Gerald Ford Jimmy Carter Ronald Reagan George Bush Sr. Bill Clinton E TF 10 The city of Boston hosted the 2004 Summer Olympics? false

Please assist me with primarily the MC function located at the bottom of the code. Second, displaying the results before exiting the program from the data saved to the file from the program read back in.

S215-Joseph-Hoffman-P2 (Running) Microsoft Visual Studio Quick Launch (Ctrl-O) File Edit iew Project Build Debug Team Tools Test Analyze Window Help Joe HottmanJH Continue a ? ?- , Application Insights*- Process: [45800] CS21 5Joseph-HoffrnanJF ? -? C5215 Joseph _Hoffm CAUsers ACEistsourcerepos CS215 Joseph_Hoftman IP2Debug CS215 Joseph Hoffman IP2.exe There exists birds that cannot fly? CS215 Joseph Ho e4 49 seconds rue 50s Gerald Ford immy Carter Ronald Reagan .George Bush Sr. 374 for (int E. Bill Clinton 100 Swer: city of Boston hosted the 2004 Summer Olympics? Memory Usage CPU Usage alse of Dl 67 % Narrie 4vcruntime14ed.dll'. Cann tucrtbased.dll. Cannot f 4msvep140d.d11'. Cannot f W64msvcp148d.dl1 4nsvcp148d.dll'. Cannot f Autos Locals Watch 1 Call Stack Breakpoints Exception Settings Command Window Immediate Window Output Error List Add to Source Control ? a ) ENG 5:17 PM E

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!