So my original code is added, now we have to change the code to allow Write a C++ program to allow the user to create a test bank of questions. The program should first ask the user how many questions he or she wishes to create. This quantity will be the first line in the test bank. The user should now be prompted for all information for each question, and then that question is written out to the test bank in the exact format specified in the Phase 2 Individual Project.
For each question, the following information should be gathered:
•Question type: Multiple choice (MC) or True/False (TF)
•Question value
•Actual question
•If the question is TF, then get answer
•If the question is MC, then get the number of options followed by each option and finally the answer
This program should be robust and allow users who make mistakes the ability to correct them (exception handling).
Can someone point me in the direction I need to take to get these results
#include <iostream>
#include <string>
usingnamespace std;
string & makeLowerCase ( string & String );
int main ( )
{
string catchGarbage; // This is used to exit.
string userInput = "";
constint NQS = 4;
string userAnswers[NQS];
string quizQuestions[NQS];
string quizAnswers[NQS];
// Question 1
quizQuestions[0] =
"There is 4 questions total\n""Question 1:\n""TF 25\n\n""There exist birds that cannot fly?\n\n""T\n""F\n";
quizAnswers[0] = "T";
// Question 2
quizQuestions[1] =
"Question 2:\n""MC 25\n\n""Who was the President of the USA in 1991?\n\n""6\n\n""A Richard Nixon\n""B Gerald Ford\n""C Jimmy Carter\n""D Ronald Reagon\n""E George Bush Sr.\n""F Bill Clinton\n";
quizAnswers[1] = "E";
// Question 3
quizQuestions[2] =
"Question 3:\n""TF 25\n\n""The city of Boston hosted the 2004 Summer Olympics?\n\n""T\n""F\n";
quizAnswers[2] = "F";
//just to even out the scoring system i put four
// Question 4
quizQuestions[3] =
"Question 1:\n""TF 25\n\n""There is nine planets?\n\n""T\n""F\n";
quizAnswers[3] = "T";
// Other variables
int a = 0; // set these right away to 0.
int s = 0;
cout << "Type 'Start' to begin the quiz, 'Help' for instructions, or 'Exit' to""quit\n" << endl;
cin >> userInput;
cout << "\n" << endl;
if ( makeLowerCase ( userInput ) == "Exit" )
{
cout << "Thanks for taking the quiz! Press Enter to exit\n";
// cin.ignore ( );
// cin.get ( );
getline ( cin, catchGarbage );
//return 0;
// evaluate to true after this.
}
if ( makeLowerCase ( userInput ) == "Help" )
{
cout << "All questions require a letter as an answer."
<< "For Multiple choice: What color is the sky. A Blue B Green C Red In this"" case, you would type 'A' for your chose"
<< "For True or False"" You will use a T or F"
<< "Good luck on your quiz\n" << endl;
cout << "Type 'Start' to begin the quiz or 'Exit' to quit\n" << endl;
cin >> userInput;
cout << "\n" << endl;
}
if ( makeLowerCase ( userInput ) == "Start" )
{
int currentQuestion;
for ( currentQuestion = 0; currentQuestion < NQS; currentQuestion++ )
{
cout << quizQuestions[currentQuestion] << endl;
cin >> userInput;
cout << endl << endl;
// check for "exit" right away.
if ( makeLowerCase ( userInput ) == "Exit" )
{
// now we can check if userInput is == "exit".
cout << "Thanks for taking the quiz! Press Enter to exit\n";
getline ( cin, catchGarbage );
break;
}
userAnswers[currentQuestion] = userInput;
if ( userAnswers[currentQuestion] == quizAnswers[currentQuestion] )
{
a++; // you can increment the score like this.
}
}
// If all the questions were successfully asked and answered, display
// the score. Otherwise, the program exits.
if ( currentQuestion == NQS )
{
s = a * 25;
if ( s == 100 )
cout << "Congratulations! You got 100% of the answers right!""\n" << endl;
else
cout << "You answered " << s << "% of questions correct!\n"
<< endl;
}
}
return 0;
}
string & makeLowerCase ( string & String )
{
for ( int index = 0; index < String.length ( ); index++ )
{
tolower ( String[index] );
}
// After all the letters are converted, return the modified version.
return String;
}