#include #include #include using namespace std; int main() { // declaring variables ifstream qdata; ifstream rdata; string question1, question2, question3, question4, question5; string answer1, answer2, answer3, answer4, answer5; string response1, response2, response3, response4, response5; int score; // initilizing score as 0 score = 0; //open files qdata.open("questions.txt"); rdata.open("responses.txt"); //read from files qdata >> question1 >> question2 >> question3 >> question4 >> question5; rdata >> response1 >> response2 >> response3 >> response4 >> response5; // prompt user for question1 cout << question1 << endl; // input response1 getline(cin, answer1); // prompt user for question2 cout << question2 << endl; // input response2 getline(cin, answer2); // prompt user for question3 cout << question3 << endl; // input response3 getline(cin, answer3); // prompt user for question4 cout << question4 << endl; // input response4 getline(cin, answer4); // prompt user for question5 cout << question5 << endl; // input response5 getline(cin, answer5); // compare answer1 with response1 if (answer1 == response1) { //increment score by 1 score++; } // compare answer2 with response2 if (answer2 == response2) { //increment score by 1 score++; } // compare answer3 with response3 if (answer3 == response3) { //increment score by 1 score++; } // compare answer4 with response4 if (answer4 == response4) { //increment score by 1 score++; } // compare answer5 with response5 if (answer5 == response5) { //increment score by 1 score++; } // compare score and display response if (score <= 1) { // display comment cout << "I think that a re-take is in order." << endl; } // compare score and display response else if (score <= 2) { // display comment cout << "You might want to study harder." << endl; } // compare score and display response else if (score <= 3) { // display comment cout << "You could use some improvement." << endl; } // compare score and display response else if (score <= 4) { // display comment cout << "Close, but not quite." << endl; } // compare score and display response else if (score < 5) { // display comment cout << "So close." << endl; } // alternative response else { // display comment cout << "Good Work!\a" << endl; } // display score cout << endl << "Your score is " << score << endl << endl; qdata.close(); rdata.close(); return 0; } // end main()