Question: #include #include #include #include using namespace std; /* This program qives a student a true/false quiz. Student enters T for true answer and F for
#include #include #include #include using namespace std; /* This program qives a student a true/false quiz. Student enters T for true answer and F for the false answer. Program stores all three: questions, answers, and student responses in three different arrays. The questions are stored in a string array and read from a file. [One question per line]. The answers are stored in an int array and read from a file. In answers file 1 represent true and 0 false. Both array have same length. Student responses are recorded in another (third) int array. The answer and student response arrays are compared. Student score is computed. If student scores 60% or more the message is given that student passed. Otherwise message is given that student failed. */ const int MAX = 20; void openFile(ifstream & input, const string & message); int fillQuestionsArray(string questions[], ifstream & inq); int fillAnswersArray(char answers[], ifstream & inq); void fillResponseArray(const string questions[], int response[], int lenQ); int GradeResponses(const char answers[], const int response[], int len); void printAnswersAndResponses(const string questions[], const char answers[], const int response[], int len); int main(){ cout << "Welcome to the quiz." << endl; ifstream in; openFile(in, "TestBank.txt"); string questions[MAX] = {}; int lenQ = fillQuestionsArray(questions, in); { for (int i = 0; i < MAX; i++); } in.close(); openFile(in, "Answers.txt"); char answers[MAX]; int lenA = fillAnswersArray(answers, in); if (lenQ != lenA){ cout << "Number of questions and answers are different. Exiting the program." << endl; exit(0); } do{ cout<<"Enter the number of questions 10 = 1 / 20 = 2";cin>>lenQ; }while(!(lenQ>=1 && lenQ<=2)); lenQ*=10; int response[MAX] = {}; fillResponseArray(questions, response, lenQ); double score = 0; score = GradeResponses(answers, response, lenQ); printAnswersAndResponses(questions, answers, response, lenQ); cout << "You scored " << score << " points, out of maximum " << lenQ << " points." << endl; double percent = (double(score) / lenQ) * 100; if (percent >= 60.0){ cout << "You scored " << percent << " % in the quiz." << endl; cout << "You passed the quiz." << endl; } else{ cout << "You scored " << percent << " % in the quiz." << endl; cout << "Sorry you failed the quiz." << endl; } in.close(); cout << "--------------------------------------------------------------------------------------------------------" << endl; return 0; } void printAnswersAndResponses(const string questions[], const char answers[], const int response[], int len){ cout << "*****************************************************" << endl; cout << "Here are correct answers and your responses." << endl; cout << "*****************************************************" << endl; cout << setw(55) << left << "Question" << setfill(' ') << setw(18) << left << "Correct Answer" << setfill(' ') << left << setw(15) << "Your Response" << endl; cout << "--------------------------------------------------------------------------------------------------------" << endl; for (int i = 0; i10) score+=0.5; else score++; } } return score; } void fillResponseArray(const string questions[], int response[], int lenQ){ cout << "Please answer the questions as asked. Questions are true or false. " << "Enter T for a true answer and F for a false answer." << endl; int ques[lenQ]; for (int i = 0; i> option; switch(option){ case 'T': case 't': response[k]=1;break; case 'F': case 'f': response[k]=0;break; default : cout<<"Invalid input";option='X'; } } while (option=='X'); } } int fillAnswersArray(char answers[], ifstream & inA){ char ch = ' '; int i = 0; while ((ch = inA.peek()) != EOF && i> answers[i]; i++; } return i; } int fillQuestionsArray(string questions[], ifstream & inq){ char ch = ' '; int i = 0; while ((ch = inq.peek()) != EOF && i
I have a few erroes, any help? Error (active) E0311 cannot overload functions distinguished by return type alone ConsoleApplication3 c:\Users\Dave\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp 23
Severity Code Description Project File Line Suppression State Error (active) E0028 expression must have a constant value ConsoleApplication3 c:\Users\Dave\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp 92
Severity Code Description Project File Line Suppression State Error (active) E0165 too few arguments in function call ConsoleApplication3 c:\Users\Dave\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp 96
Severity Code Description Project File Line Suppression State Error (active) E0020 identifier "option" is undefined ConsoleApplication3 c:\Users\Dave\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp 116
Severity Code Description Project File Line Suppression State Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? ConsoleApplication3 c:\users\dave\documents\visual studio 2017\projects\consoleapplication3\consoleapplication3\consoleapplication3.cpp 166