Jul 29, 2010 at 3:35pm UTC
somebody help ... my grade and final score is correct but i want the grade come after the final score.it sound easy but i changed every place also cant.the sequence right,but the grade always show F only.someone help ...
#include <iostream>
#include <cmath>
using namespace std;
double get_Score(double,double,double,double,double);
void grade();
int main()
{
int a ;
double score, b , c , d , e , f ;
cout << "Please enter your student number." << endl;
cin >> a;
cout << "\nPlease enter your marks for exam." << endl;
cin >> b;
cout << "\nPlease enter your marks for quiz." << endl;
cin >> c;
cout << "\nPlease enter your marks for programming assignment." << endl;
cin >> d;
cout << "\nPlease enter your marks for lab exercise." << endl;
cin >> e;
cout << "\nPlease enter your marks for test." << endl;
cin >> f;
cout << "\nStudent Number:" << " " << a << endl;
cout << "=======================";
cout << "\nMarks for exam is:" << " " << b << endl;
cout << "Marks for quiz is:" << " " << c << endl;
cout << "Marks for programming assignment is:" << " " << d << endl;
cout << "Marks for lab exercise is:" << " " << e << endl;
cout << "Marks for test is:" << " " << f << endl;
score = get_Score(b, c ,d , e ,f ); //function called here
grade();
cout << "Final Score is" << " " << score << endl;
system ("pause");
return 0;
}
double get_Score(double b ,double c ,double d ,double e , double f)
{
double score;
score = ( (b / 100) * 30 ) + ( ( c / 100) * 10 ) + ( ( d / 100) * 15 ) + ( ( e / 100) * 25) + ( ( f / 100) * 20);
return score ;
}
void grade()
{
double score;
if ( score >= 0 && score <= 49.9)
cout << "Grade is" << " " << "F" << endl;
else if ( score >= 50 && score <= 59.9 )
cout << "Grade is" << " " << "D" << endl;
else if ( score >= 60 && score <= 69.9 )
cout << "Grade is" << " " << "C" << endl;
else if ( score >= 70 && score <= 79.9 )
cout << "Grade is" << " " << "B" << endl;
else if ( score >= 80 && score <= 100 )
cout << "Grade is" << " " << "A" << endl;
return;
}
Last edited on Jul 29, 2010 at 3:37pm UTC
Jul 29, 2010 at 5:34pm UTC
you need to pass into the grade method the score returned by get_Score and get rid of the "double score;" defined within grade method.
Jul 30, 2010 at 1:42pm UTC
i still dont understand..can you show me?
Jul 30, 2010 at 1:46pm UTC
change
1 2 3 4
void grade()
{
double score;
to this:
1 2
void grade(double score)
{
and
1 2
score = get_Score(b, c ,d , e ,f ); //function called here
grade();
to this:
1 2
score = get_Score(b, c ,d , e ,f ); //function called here
grade(score);
you need to pass the score to the grade function, the grade function cant know the score if you dont tell it what the score is
thats what binarybob said
Last edited on Jul 30, 2010 at 1:47pm UTC