we are learning about reading from text files in my class. I have a list of student names along with their grade on a history test. I need to find the class average.
Here is my code so far:
For that last part, I need to find the class average so what I basically need to know is how to write the sum of the test scores so I can divide it by the number of students.Code:// File: Gradeclass.cpp // Class: ITCS 1214 TR 5pm // Purpose: To classify student's grade by // Satisfactory, Unsatisfactory, and Outstanding. #include <iostream> #include <fstream> int main() { string name_1[10], name_2[10]; int test_score[10], class_total = 0, index; float grade[10], class_average; index = 0; ifstream in_file; in_file.open("History_Exam1.txt", ios::in); for(index = 0; index < 10; index = index + 1) { in_file >> name_1[index]; in_file >> name_2[index]; in_file >> test_score[index]; } for(index = 0; index < 20; index = index + 1) { // this is where I am stuck class_average = test_score[index]
Thanks in advance for the help.



LinkBack URL
About LinkBacks




I used to be an adventurer like you... then I took an arrow to the knee.