I don't know if this is right but I need my out put to look like this and it is not working.
The average of 7 and 26 is 16
The average of 39.25 and 2.01 is 20.63
The average of
ENG101 Grade: A Credits: 3 Honor points: 12
PSY251 Grade: B Credits: 3 Honor points: 9
is 10.5
The average of 7, 26 and 100 is 44
The average of 39.25, 2.01 and 4.2 is 15.1533
The average of
ENG101 Grade: A Credits: 3 Honor points: 12
PSY251 Grade: B Credits: 3 Honor points: 9
HIS301 Grade: D Credits: 4 Honor points: 4
is 8.33333
CODE
collegeCourse operator+(const collegeCourse& l, const collegeCourse& r)
{
collegeCourse honorPoints;
honorPoints.courseID = l.courseID + r.courseID;
return honorPoints;
}
collegeCourse operator/(const collegeCourse& l, const collegeCourse& r)
{
collegeCourse honorPoints;
honorPoints.creditsEarned = l.creditsEarned/ r.creditsEarned;
return honorPoints;
}
#include <iostream>
#include <string>
#include "collegeCourse.h"
using namespace std;
template <typename T>
T average(T a, T b)
{
return (a + b) / 2;
}
template <typename T>
T average(T a, T b, T c)
{
return (a + b + c) / 3;
}
int main()
{
int a=7, b = 26, c = 100;
double d = 39.25, e = 2.01, f = 4.2;
double avg;
collegeCourse myClass[3]={collegeCourse("ENG 101", 'A', 1), collegeCourse("PSY251", 'B', 3), collegeCourse("HIS301", 'D', 4)};
cout << "The average of " << a << ", " << b << " is: " << average(7, 26) << endl;
cout << "The average of " << a << ", " << b << ", " << c << "is: " << average(7, 26, 100) << endl;
cout << "The average of " << d << ", " << e << ", " << f << " is: " << average(39.25, 2.01, 4.2) << endl;
collegeCourse anInstance;
cout << "The average of " << myClass[0] << "and " << myClass[1] << endl;
cout << " is " << endl;
collegeCourse anInstance;
cout << "The average of " << myClass[0] << " , " << myClass[1] << " and " << myClass[2] << endl;
cout << " is " << endl;
return 0;
}