Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Getting errors on lines 48,51,54,57, and 60. Saying can not convert studentType

ID: 3650301 • Letter: G

Question

Getting errors on lines 48,51,54,57, and 60. Saying can not convert studentType to studentType.

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

const int NumofStudents = 20;
const char Blank = ' ';
const string InputFile = "classRecord.txt";

struct studentType
{
string firstName;
string lastName;
int testScore;
char grade;
};

void getData (ifstream& inFile, studentType students[], int NumofStudents );
void assignGrade (studentType students[], int NumofStudents);
int highestScore (const studentType students[], int NumofStudents);
void printHSnames (int highScore, const studentType students[], int NumofStudents);
void printGrades (const studentType students[], int NumofStudents);
void holdScrn();

studentType students[NumofStudents];

int main()
{
int highScore;
ifstream inFile;


// open input file
inFile.open (Students.c_str());
if( !inFile )
{
cout << " Cannot Open The Input File: " << InputFile << " The Program is Closing Now.";
holdScrn();
return 1;
}

// Get input from file
getData (inFile, students[NumofStudents], NumofStudents);

// Assign Letter Grades
assignGrade (students[NumofStudents], NumofStudents);

// Find highest score and save it for reporting later
highScore = highestScore (students[NumofStudents], NumofStudents);

// Print Grade Report
printGrades (students[NumofStudents], NumofStudents);

// Print Highest Scores
printHSnames (highScore, students[NumofStudents], NumofStudents);

// Hold Screen
holdScrn ();
return 0;
}

// Get Data from file
void getData (ifstream& inFile, studentType students[], int NumofStudents)
{
int i;
for (int i; i < NumofStudents; i++)
{
inFile >> students[i].firstName >> students[i].lastName >> students[i].testScore;
}

// Debug
cout << " *** Input Debug ***" << endl;
for (int i; i < NumofStudents; i++)
{
cout << students[i].firstName << Blank << students[i].lastName << Blank ;
cout << students[i].testScore << endl;
}
return;

}

//Assign Grade
void assignGrade (studentType students[], int NumofStudents)
{
int i;
for (int i; i < NumofStudents; i++)
{
if (students[i].testScore >= 90)
{
students[i].grade = 'A';
}
else if (student[i].testScore >= 80)
{
student[i].grade ='B';
}
else if (student[i].testScore >= 70)
{
student[i].grade ='C';
}
else if (student[i].testScore >= 60)
{
student[i].grade ='D';
}
else {
student[i].grade ='F';
}
}
return;
}

// Find Highest Score
int highestScore (const studentType students[], int NumofStudents)
{
int highScore;
int i;
for (int i; i < NumofStudents; i++)
{
if (students[i].testScore > highScore)
{
students[i].testScore = highScore;
}
}
return highScore;
}

// Print Names of Students with the Highest Scores
void printHSnames (int highScore, const studentType students[], int NumofStudents)
{
int i;

for (int i; i < NumofStudents; i++)
{
if (students[i].testScore = highScore)
{
cout << students[i].lastName << ", " << students[i].firstName;
}
}

return;
}

// Print Grade Report
void printGrades (const studentType students[], int NumofStudents)
{
int i;

cout.width (15);
cout << "Last Name";
cout.width (15);
cout << "First Name";
cout.width (12);
cout << "Test Score";
cout.width (8);
cout << "Grade" << ' ';

for (int i; i < NumofStudents; i++)
{
cout.width (15);
cout << students[i].lastName;
cout << ", ";
cout.width (15);
cout << students[i].firstName;
cout.width (12);
cout << students[i].testScore;
cout.width (8);
cout << students[i].grade << ' ';
}
return;
}

// Holdscreen
void holdScrn()
{
char holdscr;
cout << " Enter a character and press Enter to exit. ";
cin >> holdscr;

return;
}

Explanation / Answer

please rate - thanks

compiles now, I've tried to highlight all the changes I made, but may not have. when you pass an array only pass the array name

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

const int NumofStudents = 20;
const char Blank = ' ';
const string InputFile = "classRecord.txt";

struct studentType
{
string firstName;
string lastName;
int testScore;
char grade;
};

void getData (ifstream& inFile, studentType students[], int NumofStudents );
void assignGrade (studentType students[], int NumofStudents);
int highestScore (const studentType students[], int NumofStudents);
void printHSnames (int highScore, const studentType students[], int NumofStudents);
void printGrades (const studentType students[], int NumofStudents);
void holdScrn();

studentType students[NumofStudents];

int main()
{
int highScore;
ifstream inFile;
string Students;
cout<<"Enter student file name: ";
cin>>Students;

// open input file
inFile.open (Students.c_str());
if( !inFile )
{
cout << " Cannot Open The Input File: " << InputFile << " The Program is Closing Now.";
holdScrn();
return 1;
}

// Get input from file
getData (inFile, students, NumofStudents);

// Assign Letter Grades
assignGrade (students, NumofStudents);

// Find highest score and save it for reporting later
highScore = highestScore (students, NumofStudents);

// Print Grade Report
printGrades (students, NumofStudents);

// Print Highest Scores
printHSnames (highScore, students, NumofStudents);

// Hold Screen
holdScrn ();
return 0;
}

// Get Data from file
void getData (ifstream& inFile, studentType students[], int NumofStudents)
{
int i;
for (int i; i < NumofStudents; i++)
{
inFile >> students[i].firstName >> students[i].lastName >> students[i].testScore;
}

// Debug
cout << " *** Input Debug ***" << endl;
for (int i; i < NumofStudents; i++)
{
cout << students[i].firstName << Blank << students[i].lastName << Blank ;
cout << students[i].testScore << endl;
}
return;

}

//Assign Grade
void assignGrade (studentType student[], int NumofStudents)
{
int i;
for (int i; i < NumofStudents; i++)
{
if (student[i].testScore >= 90)
{
student[i].grade = 'A';
}
else if (student[i].testScore >= 80)
{
student[i].grade ='B';
}
else if (student[i].testScore >= 70)
{
student[i].grade ='C';
}
else if (student[i].testScore >= 60)
{
student[i].grade ='D';
}
else {
student[i].grade ='F';
}
}
return;
}

// Find Highest Score
int highestScore (const studentType students[], int NumofStudents)
{
int highScore;
int i;
for (int i; i < NumofStudents; i++)
{
if (students[i].testScore > highScore)
{
highScore=students[i].testScore ;
}
}
return highScore;
}

// Print Names of Students with the Highest Scores
void printHSnames (int highScore, const studentType students[], int NumofStudents)
{
int i;

for (int i; i < NumofStudents; i++)
{
if (students[i].testScore == highScore)
{
cout << students[i].lastName << ", " << students[i].firstName;
}
}

return;
}

// Print Grade Report
void printGrades (const studentType students[], int NumofStudents)
{
int i;

cout.width (15);
cout << "Last Name";
cout.width (15);
cout << "First Name";
cout.width (12);
cout << "Test Score";
cout.width (8);
cout << "Grade" << ' ';

for (int i; i < NumofStudents; i++)
{
cout.width (15);
cout << students[i].lastName;
cout << ", ";
cout.width (15);
cout << students[i].firstName;
cout.width (12);
cout << students[i].testScore;
cout.width (8);
cout << students[i].grade << ' ';
}
return;
}

// Holdscreen
void holdScrn()
{
char holdscr;
cout << " Enter a character and press Enter to exit. ";
cin >> holdscr;

return;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote