### FINISHING TOUCHES!

Woohoo. Finally figured this bad boy out. Just a couple things I need to add that I have no idea doing.

1) How do I make it so it calculates the average of the 3 test scores and displays that instead of just displaying all 3 scores?

2) How do it so if those 3 test scores average comes back as a 50 or higher they get an "A" and if it's a 49 or lower it's an "F"?

3) How do I make it so if the person has 2 or less absences, it adds 2 points to their average?

4) How do I make it so in my final output report it puts the people with the highest averages first, I think this has something to do with sort.

SORRY THERES SO MANY, BUT I GOT THIS FAR ATLEAST! :P Thanks for anyone willing to help out, all examples are appreciated. Happy exam week!!

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051`` ``````#include #include #include #include #include using namespace std; struct Grade { std::string last, first, middle, test1, test2, test3, absence; friend std::istream &operator>>(std::istream &in, Grade &s) { return in >> s.last >> s.first >> s.middle >> s.test1 >> s.test2 >> s.test3 >> s.absence; } friend std::ostream &operator<<(std::ostream &out, const Grade &s) { return out << "Name: " << s.first << " " << s.middle << " " << s.last << std::endl << "test1: " << s.test1 << std::endl << "test2: " << s.test2 << std::endl << "test3: " << s.test3 << std::endl << "Absences: " << s.absence << std::endl; } }; void main () { std::vector grades; { std::ifstream infile ("students.txt"); Grade temp; while(infile >> temp) { grades.push_back(temp); } } for(size_t i = 0; i < grades.size(); ++i) { std::cout << grades[i] << std::endl; } } ``````
 1) How do I make it so it calculates the average of the 3 test scores and displays that instead of just displaying all 3 scores?

Add the three scores together, divide by three, display that value.
Topic archived. No new replies allowed.