hello there. i need to do a program that calculate the final grade of a list of students that is in a datafile.txt i have 4 datafiles in for of a list 1 student's names the other one is the midexam grades, the other the finalexam grades, and the quizes grades. the problem i have is that when i open the file it only show me the first name in the list and the calculation of the first student many times i do not know how to do to show all the list with their final grades. ill apriciateany help thank you.
void myMenu()
{
cout <<""<< endl;
cout <<" Please enter your selection"<<endl;
cout <<""<< endl;
cout << " Enter # 1 to enter new student data"<< endl;
cout << " Enter # 2 to show "<< endl;
cout << " Enter # 3 to exit"<< endl;
}
class myStudent
{
private:
char lName[26];
int midExam;
int finExam;
double aveAssign;
double finGrade;
if (myfile.is_open()) // do it only if the file is open
{
//while (!myfile.eof()) // to the end of file
//{
//for (int i=0; i<46; ++i )
{
myfile >> lName;
myfile1 >> midExam;
myfile2 >> finExam;
myfile3 >> aveAssign;//[k]; // Here we are writing to the array
//cout << lName <<'\t'<< endl;
}
myfile.close();
}
else cout << " Ooops we cannot open file" << endl;
//cout <<" Please enter student's last name: ";
//cin >> lName;
//cout <<" Please enter student's midterm exam grade: ";
//cin >> midExam;
//cout <<" Please enter student's final exam grade: ";
//cin >> finExam;
//cout <<" Please enter student's average Assignment grade: ";
//cin >> aveAssign;
}
int main()
{
myStudent student [5]; // Max student number is 5
int option;
double sum =0;
myMenu();
cin >> option;
while (option!=3)
{
if (option == 1)
{
for (int i =0; i <5; i++)
{
//cout <<""<< endl;
//cout<<" This is student "<<endl;//i+1<<"."<<endl;
student[i].getData();
}
}
else if (option == 2)
{
cout <<setw(10)<<"Last Name"<<setw(15)<<"Final Grade"<< endl;
for (int i = 0; i<5; i++)
{
student[i].calFinGrade();
student[i].showFinGrade();
cout <<""<< endl;
cout<<"=============================================="<< endl;
cout<<" EXITING FROM THE PROGRAM "<< endl;
cout<<"============================================="<< endl;
system ("pause");
return 0;
}