I am having trouble figuring out how to get this program to work correctly and was wondering if someone could give me a little guidance? I know the problem is in the last function Grade::getWeightedGrade() but I can't figure out what I am doing wrong. The program runs correctly but instead of returning the right score it returns zero. The score is supposed to be based upon the ( score of the test * (weight / 100) for both grade1 and grade2 and then these totals are added together to give the final score....
Here is what it should run like:
Enter Type: Midterm
Enter Score: 86
Enter Weight: .40
Enter Type: Final
Enter Score: 97
Enter Weight: .60
Your grades are as follows:
Midterm 86, which counts 40%
Final 97, which counts 60%
Your final grade is: 92.6
Code:
#include <iostream>
#include <string>
using namespace std;
class Grade
{
public:
void enterGradeInfo();
void showGradeInfo();
double getWeightedGrade();
private:
int mWeight;
int mScore;
string mType;
};
int main()
{
Grade grade1;
Grade grade2;
grade1.enterGradeInfo();
grade2.enterGradeInfo();
cout << "Your grades are as follows:" << endl;
grade1.showGradeInfo();
grade2.showGradeInfo();
cout << "Your final grade is " << grade1.getWeightedGrade + grade2.getWeightedGrade;
cout << endl;
system("pause");
return 0;
}
void Grade::enterGradeInfo()
{
cout << "Enter type: ";
cin >> mType;
cout << endl;
cout << "Enter Score: ";
cin >> mScore;
cout << endl;
cout << "Enter weight: ";
cin >> mWeight;
cout << endl;
}
void Grade::showGradeInfo()
{
cout << mType << " which counts for " << mWeight << "%" << endl;
}
double Grade::getWeightedGrade()
{
return mScore * (mWeight/100) ;
}