I'm stuck, I'm not sure how to calculate a line from a txt file I import into the program. The txt file has a set of 4 grades for each line, I have to calculate the average for each one and display it which I can do but I'm not sure how to get IDE to read each line and find the average.
int main()
{
//Each line represents the four tests taken by students in a class during the semester.
//You need to calculate the average for each student in the class by reading in the file.
//Display the average for each student along with their letter grade.
int infile;
string number;
ifstream myfile ("Grades.txt");
if (myfile.is_open())
{
while ( getline (myfile, number) )
{
cout << number << endl;
}
myfile.close();
}
else cout << "Unable to open file.";
while (myfile >> number)
{
cout << number << endl;