Question: #include #include #include #include using namespace std; string lastNames[40]; int scores[40][5]; int students; double averageScore[40][5]; char letterGrade[40]; void readData(ifstream& infile); char calGrade(double averageScore); void outputData

#include

#include

#include

#include

using namespace std;

string lastNames[40];

int scores[40][5];

int students;

double averageScore[40][5];

char letterGrade[40];

void readData(ifstream& infile);

char calGrade(double averageScore);

void outputData (ofstream& outdata);

int main()

{

ifstream infile;

ofstream outdata;

readData(infile);

outputData(outdata);

return 0;

}

void readData(ifstream& infile);

int score;

int i = 0;

char grade;

float avgScore = 0.00, totalScore;

ifstream infile;

inFile.open("scores.txt");

cout << setprecision(2) << avgScore << endl;

if(!infile)

{

cout << "Cannot open the input file." << endl;

return 1;

}

else

{

while(infile)

{

totalScore = 0.0;

infile >> name;

lastNames[i] = name;

for(int j = 0; j < 5; j++)

{

infile >> score;

scores[i][j] = score;

totalScore += score;

}

averageScore = totalScore / 5;

averageScore[i] = avg;

grade = letterGrade(avg);

grades[i] = grade;

i++;

students ++;

}

infile.close();

}

}

char letterGrade(double averageScore);

{

char grade;

if (averageScore >= 90 && averageScore <= 100)

grade = 'A';

else if (averageScore >=80 && averageScore <= 89)

grade = 'B';

else if (averageScore >=70 && averageScore <= 79)

grade = 'C';

else if (averageScore >= 60 && averageScore <= 69)

grade = 'D';

else if (averageScore >= 0 && averageScore <= 59)

grade = 'F';

return grade;

}

void outputData(ofstream& outdata)

outdata.open("grades.txt")

cout << "Last name\tScore1\tScore2\tScore3\tScore4\tScore5\tAvg\tGrade" << endl;

cout << "---------\t------\t------\t------\t-------\t------\t---\t-----" << endl;

outdata << "Last Name\tScore1\tScore2\tScore3\tScore4\tScore5\tAvg\tGrade" << endl;

outdata << "---------\t------\t------\t------\t------\t------\t---\t-----" << endl;

for (int i = 0; i < students; i++)

{

cout << setw(10) << lastnames[i] << "\t";

outdata << setw(10) << lastnames[i] << "\t";

for (int j = 0; j < 5; j++)

{

cout << scores[i][j] << "\t";

outdata << scores[i][j] << "\t";

}

cout << averageScore[i] << "\t" << grades[i] << endl;

outdata << averageScore << "\t" << grades[i] << endl;

}

dataOut.close();

}

}

}

exit status 1 main.cpp:28:1: error: 'inFile' does not name a type; did you mean 'infile'? inFile.open("scores.txt"); ^~~~~~ infile main.cpp:29:1: error: 'cout' does not name a type cout << setprecision(2) << avgScore << endl; ^~~~ main.cpp:31:1: error: expected unqualified-id before 'if' if(!infile) ^~ main.cpp:36:1: error: expected unqualified-id before 'else' else ^~~~ main.cpp:58:1: error: expected declaration before '}' token } ^

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!