Nadroj,
Okay, I can totally understand that. Thanks. I've done what you suggested, but somewhere along the way I made a mistake and I have two problems: 1.) findLowest always returns 2, and 2.) the scores in calcAverage are all zeroes. Grd1, grd2, etc. are not even consistent with s1, s2, etc.
Thanks for all your patience thus far. I'm actually a design major and am taking this course for fun, but lately I've found myself struggling with it.
Here's findLowest:
Code:
int findLowest(double tScore1, double tScore2, double tScore3, double tScore4, double tScore5)
{
double lowest = 100;
int index;
if (lowest > tScore1)
{
lowest = tScore1;
index = 1;
}
else if (lowest > tScore2)
{
lowest = tScore2;
index = 2;
}
else if (lowest > tScore3)
{
lowest = tScore3;
index = 3;
}
else if (lowest > tScore4)
{
lowest = tScore4;
index = 4;
}
else if (lowest > tScore5)
{
lowest = tScore5;
index = 5;
}
return index;
}
And calcAverage:
Code:
void calcAverage(double grd1, double grd2, double grd3, double grd4, double grd5)
{
double s1, s2, s3, s4, s5;
double lowest, average;
lowest = findLowest(grd1, grd2, grd3, grd4, grd5);
cout << lowest << endl << endl; //for debugging
if (lowest = 1)
{
average = (s2 + s3 + s4+ s5)/4;
cout << "Four highest test scores: " << fixed << s2 << ", " << s3 << ", " << s4 << ", " << s5 << endl;
cout << "Average: " << fixed << average << endl;
}
else if (lowest = 2)
{
average = (s1 + s3 + s4+ s5)/4;
cout << "Four highest test scores: " << fixed << s1 << ", " << s3 << ", " << s4 << ", " << s5 << endl;
cout << "Average: " << fixed << average << endl;
}
else if (lowest = 3)
{
average = (s1 + s2 + s4+ s5)/4;
cout << "Four highest test scores: " << fixed << s1 << ", " << s2 << ", " << s4 << ", " << s5 << endl;
cout << "Average: " << fixed << average << endl;
}
else if (lowest = 4)
{
average = (s1 + s2 + s3+ s5)/4;
cout << "Four highest test scores: " << fixed << s1 << ", " << s2 << ", " << s3 << ", " << s5 << endl;
cout << "Average: " << fixed << average << endl;
}
else if (lowest = 5)
{
average = (s1 + s2 + s3+ s4)/4;
cout << "Four highest test scores: " << fixed << s1 << ", " << s2 << ", " << s3 << ", " << s4 << endl;
cout << "Average: " << fixed << average << endl;
}
}