I believe this to be a simple problem. My program runs fine, but I cannot figure why the variable "final_grades" is not being passed to the function and output. alternatively, I may be calling to the function incorrectly. This is the first class that I have written, so it may be that I haven't declared it correctly. The book that I'm using is usually great, but for this problem it's not helping me.
When I run the program and input values I simply don't get any output, but when I put the output statement in the main function body it works fine. I need to use a function in the class, however, as specified in this assignment.
Thank you in advance for your help.
#include <iostream>
using namespace std;
class All_Grades
{
public:
void output_grades(double final_grade);
double quiz_1, quiz_2, midterm, final_exam;
};
int main()
{
All_Grades student;
double quiz_percent, midterm_percent, final_percent, final_grade;
cout << "Please input the grades for this student as you are prompted on the screen ";
cout << ",making sure to push enter between each grade." <<endl;
cout <<endl;
cout << "Note: If the numbers entered do not fall within acceptable values,";
cout << "the program will terminate. For example, entering 12 as a grade for quize one" <<endl;
cout << "(which has a maximum value of 10, is not valid." <<endl;
cout << "The grade for quiz 1: ";
cin >> student.quiz_1;
cout << "for quiz 2: ";
cin >> student.quiz_2;
cout << "for the midterm: ";
cin >> student.midterm;
cout << "for the final exam: ";
cin >> student.final_exam;
quiz_percent = ((student.quiz_1 + student.quiz_2) / 20) * 25;
midterm_percent = (student.midterm / 100) * 25;
final_percent = (student.final_exam / 100) * 50;
final_grade = quiz_percent + midterm_percent + final_percent;
student.output_grades();
return 0;
}
void All_Grades::output_grades(double final_grade)
{
cout << "The final grade for this student is " << final_grade;
}