ok So this program takes a students four scores and reports back their grade but it is not working and reports the grade F every time. I tried cout<< q1 and it gived bogus answers so i don't think anything was ever assigned to that variable then but I don't know how to fix it i am just a beginner thank you!
int main()
{
int n,i;
double q1,q2,mid,final,quiz1,quiz2,midterm,finalexam;
grading student;
cout << "Enter the number of students:\n";
cin >> n;
for (i=0;i<n;i++)
{
student.getscores();
student.setscores(quiz1,quiz2,midterm,finalexam);
student.grade(q1,q2,mid,final);
}
}
void grading::getscores()
{
double quiz1,quiz2,midterm,finalexam;
cout << "Enter the score for quiz #1:\n";
cin >> quiz1;
cout << "Enter the score for quiz #2:\n";
cin >> quiz2;
cout << "Enter the score for the midterm:\n";
cin >> midterm;
cout<< "Enter the score for the final exam:\n";
cin >> finalexam;
}
cout << q1;
if (total >= 90)
cout << "The student's grade is an A.\n";
else if ((total < 90) && (total >= 80))
cout << "The student's grade is a B.\n";
else if ((total < 80) && (total >= 70))
cout << "The student's grade is a C.\n";
else if ((total < 70) && (total >= 60))
cout << "The student's grade is a D.\n";
else
cout << "The student's grade is an F.\n";
}
What happens in the below section, stays in the below section.
1 2 3 4 5 6 7 8 9 10 11 12
void grading::getscores()
{
double quiz1,quiz2,midterm,finalexam;//These data are only maintained here
cout << "Enter the score for quiz #1:\n";
cin >> quiz1;
cout << "Enter the score for quiz #2:\n";
cin >> quiz2;
cout << "Enter the score for the midterm:\n";
cin >> midterm;
cout<< "Enter the score for the final exam:\n";
cin >> finalexam;
}
Why don't you design your getscores function like your setscores function?