I think the code comments show what is needed.
Essentially, I just need to spit out the members name and score who are below the average score in the list.
void displayLowScore(struct payload *arrayStart , //first element of array
struct payload *arrayEnd ) //last element of array
{
int memberCount = 0; //total number of members in list/array
int totalScore = 0; //accumulated value of all scores added together
float averageScore; //totalScore / memberCount
struct payload *tempPtr ; //pointer for traversing
// label
// -----
cout << "Members below average: ";
// Traverse array accumulating totalScore.
// (Don't destroy any of the parameters ...
// you need them for a second traverse: use
// tempPtr).
// -------------------------------------------
for (tempPtr = arrayStart; tempPtr != arrayEnd+1; ++tempPtr)
totalScore = totalScore + tempPtr; // cannot get this to work correctly. Current code gives exception.
// calculate member average
// --------------------------
if (memberCount == 0)
averageScore = 0;
else
averageScore = (float)totalScore / (float)memberCount;
cout << averageScore << endl;
// Traverse array & output every member & score below the average
// Make sure to handle your traversal pointer in both cases:
// member below average & member>= average.
// ---------------------------------------------------------------
//CODE NEEDED HERE
//CODE NEEDED HERE