Function Not Working Correctly!

Hey everyone, used this site for a while and its really helped me a lot. However, i'm struggling to figure this out. I can't get the function "ratethegroup" to work! It just isnt printing anything correctly. Thank you in advance..

http://codepad.org/M9KLOIlz
Last edited on
If u write the function here only then any1 will b able to help! Without no1 will knw whats the prob!
It's all on the codepad, function is near the bottom of the program as "ratethegroup". This is it though, thank you very much. I can't get it to work! It doesn't print the right numbers when i enter them. Thank you!

void ratethegroup (int ScoreOne, int ScoreTwo, int ScoreThree, int TotalScore)
{


if (ScoreOne>=700 && ScoreTwo>=700 && ScoreThree>=700 && TotalScore>=2100){
cout<<endl<<"Group Grade: Outstanding!"<<endl;
outfile<<endl<<"Group Grade: Outstanding!"<<endl;
return;
}

if (ScoreOne>=700 && ScoreTwo>=700 && TotalScore>=2100){
cout<<endl<<"Group Grade: Very Good."<<endl;
outfile<<endl<<"Group Grade: Very Good."<<endl;
return;
}

if (ScoreOne>=700 && ScoreThree>=700 && TotalScore>=2100){
cout<<endl<<"Group Grade: Very Good."<<endl;
outfile<<endl<<"Group Grade: Very Good."<<endl;
return;
}

if (ScoreTwo>=700 && ScoreThree>=700 && TotalScore>=2100){
cout<<endl<<"Group Grade: Very Good."<<endl;
outfile<<endl<<"Group Grade: Very Good."<<endl;
return;
}

if (ScoreTwo>=700 && TotalScore>=2100){
cout<<endl<<"Group Grade: Lop-Sided."<<endl;
outfile<<endl<<"Group Grade: Lop-Sided."<<endl;
return;
}

if (ScoreOne>=700 && TotalScore>=2100){
cout<<endl<<"Group Grade: Lop-Sided."<<endl;
outfile<<endl<<"Group Grade: Lop-Sided."<<endl;
return;
}

if (ScoreThree>=700 && TotalScore>=2100){
cout<<endl<<"Group Grade: Lop-Sided."<<endl;
outfile<<endl<<"Group Grade: Lop-Sided."<<endl;
return;
}

if (ScoreOne<=500 && TotalScore<2100){
cout<<endl<<"Group Grade: Weak."<<endl;
outfile<<endl<<"Group Grade: Weak."<<endl;
return;
}

if (ScoreTwo<=500 && TotalScore<2100){
cout<<endl<<"Group Grade: Weak."<<endl;
outfile<<endl<<"Group Grade: Weak."<<endl;
return;
}

if (ScoreThree<=500 && TotalScore<2100){
cout<<endl<<"Group Grade: Weak."<<endl;
outfile<<endl<<"Group Grade: Weak."<<endl;
return;
}

if (ScoreOne<500 && ScoreTwo<500 && ScoreThree<500){
cout<<endl<<"Group Grade: Erratic."<<endl;
outfile<<endl<<"Group Grade: Erratic."<<endl;
return;
}

return;
}
Last edited on
1) Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

2) Can you be more specific about your problem? What values are you inputting? What output are you getting? In what way is the output not what you expect?

Help us to help you by being as precise and complete as possible.

EDIT:

3) One thing I can see is that the value of TotalScore that gets passed into ratethegroup() is always going to be 0. You pass a zero into classify(), and nothing changes it before it gets passed into ratethegroup().
Last edited on
I would store the scores in an array so you can access them with loops.

Looking at the code, scores fall into the following "bands":
0-500
501-700
701-799
800

I'd write a function that takes a score and returns the band that it's in (as an enum if you've learned about that those, or just a number 0-3 if you haven't).

Then to rate the group, get the band for each score and count the number of scores in each band. You can use this to determine the rate.
Topic archived. No new replies allowed.