int static counter = 0;
int static total = 0;
char input;
char answer;
string typedInput;
string typedAnswer;
bool correct;
bool checkCharAnswers(char input, char answer);
bool checkStringAnswers(string typedInput, string typedAnswer);
void counting(bool correct);
void charMessage(bool correct, char answer);
void stringMessage(bool correct, string typedAnswer);
void displayResult(int counter, int total);
void question1();
void question2();
void question3();
void question4();
void question5();
void question6();
void question7();
void question8();
void question9();
void question10();
int main()
{
cout << "WELCOME to the review for UnsortedLists and SortedLists" << endl;
cout << "If you find any errors or have any ideas to better improve my code,
please let me know. I might not have spent a million hours putting this together."
<< endl << endl;
cout << "NOTE: Be wary that by using strings to hold standard input, whitespace
is also taken into consideration when comparing answers. Always check the outputted
answer when the program claims your answer was 'wrong'" << endl << endl;
question1();
question2();
question3();
question4();
question5();
question6();
question7();
displayResult(counter, total);
}
void question1()
{
answer = 'A';
cout << endl <<
"--------------------------------------------------------------------" << endl;
cout << "When deleting an item in an unsorted list, what do you have to check
first?" << endl;
cout << "A. if the list is empty" << endl;
cout << "B. if the list is full" << endl;
cout << "C. if the user inputted numbers" << endl;
, cout << "D. if the user provided their name" << endl;
counter++;
cout << "Type the letter for your answer... ";
cin >> input;
correct = checkCharAnswers(input, answer);
counting(correct);
charMessage(correct, answer);
}
void question2()
{
typedAnswer = "midpoint = (first + last)/2;";
string typedAnswer2 = "midpoint = (last + first)/2;";
cout << endl <<
"--------------------------------------------------------------------" << endl;
cout << "Referring to the binary search discussed in lecture and homework,
there are three variables named: 'first', 'last', and 'midpoint'. Write the math
expression to calculate the midpoint." << endl;
cin.ignore();
cout << "Type your answer (don't forget the semicolon)... ";
getline(cin, typedInput);
counter++;
counting(correct);
if (checkStringAnswers(typedInput, typedAnswer) == true ||
checkStringAnswers(typedInput, typedAnswer2) == true)
{
cout << "Good job" << endl;
correct = true;
}
else
{
correct = false;
stringMessage(correct, typedAnswer);
cout << endl;
cout << "OR" << endl;
cout << endl;
stringMessage(correct, typedAnswer2);
}
}
void question3()
{
answer = 'B';
cout << endl <<
"--------------------------------------------------------------------" << endl;
cout << "What is the Big O for a binary search of a SortedList list?" << endl;
cout << "A. 0(1)" << endl;
cout << "B. 0(log n)" << endl;
cout << "C. 0(n)" << endl;
cout << "D. 0(ln n)" << endl;
counter++;
cout << "Type the letter for your answer... ";
cin >> input;