Question: my code: #include #include #include #include using namespace std; struct studentData { string studentFName; string studentLName; int testScore; float total_testscore; char grade; }; int n=
my code:
#include #include #include #include using namespace std;
struct studentData { string studentFName; string studentLName; int testScore; float total_testscore; char grade; }; int n= 20; // n is for no. of students
//function declaration void getData(ifstream&, struct studentData student[]) { ifstream infile; infile.open("Studentdata.txt"); if (!infile) { cout << "file contain error"; } else if (!infile.eof()) { for (int i = 0;i < n;i++) { infile >> student[i].studentFName; infile >> student[i].studentLName; infile >> student[i].testScore; } }
}
void output_result(ofstream&, studentData student[]) {
ofstream outfile;
outfile.open("outputStudent.txt");
for (int i = 0;i < 20;i++) {
outfile << student[i].studentFName << " " << student[i].studentLName << " " << student[i].testScore << " " << student[i].grade << " " << endl; }
}
void printData(studentData student[]) {
} int main() { ifstream infile; //open input file infile.open("Studentdata.txt");
studentData student[20];
ofstream outfile; outfile.open("outputStudent.txt");
}
question :
The program should read in the data till end of file is found (or the maximum students is reached) and then process the data as described here. The program should output each students name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score.
Student data should be stored in an array of structures. The structure should contain the following members; studentFName and studentLName of type string, testScore of type int , and grade of type char . Suppose that the class has 20 students. The array should be 20 elements long. Try to use exception handling in the event invalid data is found while reading the data file.
Your program must contain at least the following functions:
- A function to read the students data into the structure array from a data file
- A function to assign the relevant grade to each student.
- A function to find the highest test score.
- A function to print the names of the students having the highest test score.
Your program must output each students name in this form: last name followed by a comma, followed by a space, followed by the first name; the name must be left justified. Moreover, other than declaring the variables and opening the input and output files, the function main should only be a collection of function calls.
You create your test data text file but it should be no more than 20 rows of data which have 2 names and a test score. It may look something like this:
The program should read in the data till end of file is found (or the maximum students is reached) and then process the data as described here. The program should output each students name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score.
my question:
please edit my code. i want in c++
i want answer as soosn as possible please help me.
i don't want copyable code from othe rchegg sources.
input file:
James Dean 95
Thomas O'Brien 100
Jon Smith 85
Bob Hope 83
Barbara White 99
Timothy Thompson 75
Bob Barker 84
Kathleen Dix 77
Joelle Howard 98
Michelle Chingwa 100
Jeanette Harris 75
Doris Kishigo 99
Marina Favela 68
Kimberly Roe 76
Eliza Little 80
Amelia Awnemequom 87
Terri Hatchett 70
Joan Joneson 73
Anna Smith 72
Celia Bulgarelli 81
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
