Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (anonymous):

I need help help calculating and updating the total grade for a structure student inside an array.

OpenStudy (fortytherapper):

In C++? Have you tried the source code, if so?

OpenStudy (anonymous):

yes, for c++

OpenStudy (anonymous):

and what do you mean source code?

OpenStudy (anonymous):

I'm getting data from a file with various parts i.e id, first name, last name, midterm, final,quizzes, labs, projects

OpenStudy (anonymous):

and these things make up the structure student

OpenStudy (fortytherapper):

Like, have you attempted the code and get errors? If so, would you mind posting so I give a quick look? I gotta go in 10 minutes and won't be back til tomorrow. I don't mind helping though

OpenStudy (anonymous):

okay

OpenStudy (anonymous):

I am using functions

OpenStudy (anonymous):

void fillArrayFromFile(ifstream& ins,student studentArray[], int& numberOfStudents, int weightMidterm, int weightFinal, int weightQuizzes, int weightLabs, int weightProjects) { int id; string firstName; string lastName;; string line; numberOfStudents = 0; while (!ins.eof()) { ins >> studentArray[numberOfStudents].id >> studentArray[numberOfStudents].first >> studentArray[numberOfStudents].last >> studentArray[numberOfStudents].midterm >> studentArray[numberOfStudents].final >> studentArray[numberOfStudents].quizzes >> studentArray[numberOfStudents].labs >> studentArray[numberOfStudents].project; numberOfStudents++; } } void updateTotalGrade(student studArray[], int index, int weightMidterm, int weightFinal, int weightQuizzes, int weightLabs, int weightProject) { int totalGrade; index = 0; for (int i = 0; i < index; i++) { } }

OpenStudy (anonymous):

updateTotalGrade is called by fillArrayFromFile

OpenStudy (anonymous):

@FortyTheRapper

OpenStudy (fortytherapper):

So are you trying to create a struct like...? struct blahblah { }; Then wanting to print out the values of the files in main or the function?

OpenStudy (anonymous):

just store the informantion in the struct

OpenStudy (anonymous):

the struct is already created

OpenStudy (anonymous):

struct student // stucture of type student. { int id; string first; string last; float midterm; float final; float quizzes; float labs; float project; float totalGrade; string letterGrade; };

OpenStudy (anonymous):

this is what the file contains

OpenStudy (anonymous):

@FortyTheRapper

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!