Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help making this program run. #include #include #include #include #include using namespace std; // function prototypes void readDataFile(ifstream &, char[], string[], string[]); void

I need help making this program run. #include #include #include #include #include using namespace std; // function prototypes void readDataFile(ifstream &, char[], string[], string[]); void calculateScores(char[],string[], double[]); void calculateGrades(double[], char[]); // global declarations for constants const int MAX_ANSWERS = 20; const int MAX_Students = 200; const double MAX_Marks = 40.0; // global declarations for a variable int studentsCounter = 0; // start main function int main() { // variables declaration ifstream inFile; string fileName; char testAnswers[MAX_STUDENTS]; string studentID[MAX_STUDENTS]; string studentAnswers[MAX_STUDENTS]; double studentScores[MAX_STUDENTS]; char studentGrades[MAX_STUDENTS]; // prompt the usre to enter the name of a file cout<< "Enter the file name"; cin>> fileNAME; // open the file and display an error message if the //file not found inFile.open(fileName); if (!inFile) { //display an error message if the file not found // and exit the program cout<< "The file"<>testAnswers[i]; // read student id index = 0; inFile >> studentID[index]; while (inFile) { // imcrement the number of students studentsCounter++; // read space character inFile.get(ch); // read student answers getline(inFile, studentAnswers[index]); // go for next student inFile >> studentID[index]; }// end while }// end of readDataFromFile function // calculateScores function definition void calculateScores(char testAnswers[], string studentAnswers[], double studentScores[]) } // local variables string answers; double sum; // repeat the loop for all students for (int = 0; i < studentsCounter; i++) { // get answers of each student as string answers = studentAnswers[i]; sum = 0; //repeat the loop for all answers of each student for (int j = 0; j < answers.length(); j++) } if (answers[j] =='') // add 0 if the answer is empty sum = sum + 2; else // subtract 1 if the answer is wrong sum = sum -1; } // end inner for // store the score of each student studentScores[i] = sum; } // end outer for } // end of calculateScores function

TFFTFFTTTTFFTFTFTFTT

ABC54301 TFTFTFTT TFTFTFFTTFT ABC59310 TFFTFFTTTTFFTFTFTFTT ABC39583 FTTFTFTTFTFFFTFTTTFTF ABC38493 FTFTTFTFTFTTF TFFTTT ABC10394 FTTFTFTFFTFTFTTFTTFT ABC10006 FTFTFFFTFFTFTFTFFTFT ABC10007 TFFTFFTTTTFFTFTFTTFT ABC38558 FTFTTFTFFTFFFTFTFTFF ABC10439 FTTTFTFTFTFTTFTFTFFT ABC10010 FTTFTFFFFTFTTTFTFTFT ABC10011 FTFFTFTTFTFTFFFTFTFT ABC10512 FTFFTTTFTFTTTFTFTFTF ABC10013 FFTTFTFTFFFTFTFFTFTT ABC10014 TFFTFFTTTTFFTFTFTFTT ABC10016 FTTTFTFTTFFTFTTFTFTT ABC10017 TFFTFFTTTTFFTFTFTFTT

TFFTFFTTTTFFTFTFTFTT

ABC54301 TFTFTFTT TFTFTFFTTFT 11 F ABC59310 TFFTFFTTTTFFTFTFTFTT 40 A ABC39583 FTTFTFTTFTFFFTFTTTFTF 7 F ABC38493 FTFTTFTFTFTTF TFFTTT 8 F ABC10394 FTTFTFTFFTFTFTTFTTFT 4 F ABC10006 FTFTFFFTFFTFTFTFFTFT 13 F ABC10007 TFFTFFTTTTFFTFTFTTFT 34 B ABC38558 FTFTTFTFFTFFFTFTFTFF 1 F ABC10439 FTTTFTFTFTFTTFTFTFFT 16 F ABC10010 FTTFTFFFFTFTTTFTFTFT -5 ABC10011 FTFFTFTTFTFTFFFTFTFT 4 F ABC10512 FTFFTTTFTFTTTFTFTFTF 10 F ABC10013 FFTTFTFTFFFTFTFFTFTT 10 F ABC10014 TFFTFFTTTTFFTFTFTFTT 40 A ABC10016 FTTTFTFTTFFTFTTFTFTT 13 F ABC10017 TFFTFFTTTTFFTFTFTFTT 40 A This is the error I am getting.

ain.cpp:1:9: error: #include expects "FILENAME" or main.cpp:2:9: error: #include expects "FILENAME" or main.cpp:3:9: error: #include expects "FILENAME" or main.cpp:4:9: error: #include expects "FILENAME" or main.cpp:5:9: error: #include expects "FILENAME" or main.cpp:108:18: error: empty characterconstant if (answers[j] =='') ^ main.cpp:8:19: error: variable or fieldreadDataFile declared void void readDataFile(ifstream &, char[], s ^ main.cpp:8:19: error: ifstream was not declared in this scope main.cpp:8:29: error: expected primary-expression before

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions