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!!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <ctime>
#include <fstream>
#include <string>
#include <vector>
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<Grade> 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.