Ok so we have made a test exam program I got that to work. we needed to make a menu driven program got that to work. Now I have to pull it together where if they hit the number one it pulls up the test bank if they hit two its basically the answers. so number 2 or case 2 I had working but when I was trying to integrate my test into case one it doesn't work. I'm just trying to figure out how to make this work I'm sure its all jacked up but if someone can help.
Pu#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
string & makeLowerCase ( string & String ); //just added
int main()
{
int counter, choice;
do
{
cout << "1) Load an exam" << endl;
cout << "2) Display an exam" << endl;
cout << "3) Quit program" << endl;
cin >> choice;
switch(choice)
{
case 1:
// begining of new
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;
break;
case 2:
cout <<"Question 1\n"
<<"True or False worth 25 points\n"
<<"There exist birds that cannot fly?\n"
<<"Answer is True\n\n";
cout <<"Question 2\n"
<<"Multiple Choice worth 25 points\n"
<<"Who was the President of the USA in 1991?\n"
<<"Answer is E George Bush Sr. \n\n";
cout <<"Question 3\n"
<<"True or False worth 25 points\n"
<<"The city of Boston hosted the 2004 Summer Olympics?\n"
<<"Answer is False\n\n";
cout <<"Question 4"
<<"True or False worth 25 points\n"
<<"There is nine planets?\n"
<<"Answer is True\n\n";
cout << endl;
break;
// Case 3 ends program if picked
case 3:
cout << "Thanks. See you again, later.." << endl << endl;
return 0;
default:
cout << "Options are only choices 1 to 3.. Thank you." << endl;
}
}while (choice >=1 || choice <=3);
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;
}//end of new
}t the code you need help with here.