write a void function named topStudents with one parameter, an array of studentT
ID: 3644612 • Letter: W
Question
write a void function named topStudents with one parameter, an array of studentType that outputs the first and last name of every student with a grade A.Will rate! thanks!
Explanation / Answer
#include #include #include #include using namespace std; struct studentType { string studentFName; //Stores the student's first name string studentLName; //Stores the student's last name int testscore; //stores the test score char grade; //stores letter grade }; studentType students[20]; //initializes an array called students of the type studentType void getData(studentType sList[], int listSize); void calculateGrade(studentType sList[], int listSize); int highestScore(const studentType sList[], int listSize); void printResult(const studentType sList[],int listSize); void StuRead(ifstream& indata, studentType students[]) { int x = 0; for (x = 1; x < 20; x++) { inFile >> students[x].studentLName //receiveing error 'inFile' undeclared identifier even though I have it in main >> students[x].studentFName >> students[x].testscore; } } char AssignGrade(char LetterGrade, studentType students[]) { char grade = 0; //variable to hold the students grade if(LetterGrade > 90) grade = 'A'; else if (LetterGrade > 80) grade = 'B'; else if (LetterGrade > 70) grade = 'C'; else if (LetterGrade > 60) grade = 'D'; else if (LetterGrade < 59) grade = 'F'; return grade; } void Highest(students[20]) //function to find the student with the highest grade { //receive the following error at this line: 'Highest':function-style initializer appears to be function definition int highTest = 0; for(x = 0; x < 20; x++) { if(x > highTest) highTest = x; } } int main () { ifstream inFile; inFile.open("c:\temp\studentData.txt"); ofstream outFile; outFile.open("c:\temp\studentResults.txt"); StuRead(inFile, studentType students[]); //receive the following errors at this line: syntax error expected ')' //syntax error: missing ')' before identifier "students' //'studenType': illegal use of this type of expression return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.