HELP W/ Video Game Program assignment.

I am in desperate need of help, I have an assignment to figure out the average of players intered into my program. The code runs but it is not showing the average score neither is it showing Players who scored below average. I am also getting this message when I run the program --Average Score: -1 .# IND ( Why am I getting this plaese?)
PLEASE HELP !!!. This is what I have so far...

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

const int array_size=100;
void InputData(string playerNameAr[], int scoreAr[], int &numPlayersRef);
void DisplayPlayerData(const string playerNameAr[], const int scoreAr[], int numPlayers);
double CalculateAverageScore(const int scoreAr[], int numPlayers);
void DisplayBelowAverage(const string playerNameAr[], const int scoreAr[], int numPlayers, double averageScore);
int main()
{
string playerNameAr[array_size];
int scoreAr[array_size];
int numPlayers = 0;
double averageScore;
averageScore = CalculateAverageScore(scoreAr, numPlayers);
cout << fixed << showpoint << setprecision(2);
InputData(playerNameAr, scoreAr, numPlayers);
DisplayPlayerData(playerNameAr, scoreAr, numPlayers);
DisplayBelowAverage(playerNameAr, scoreAr, numPlayers, averageScore);void InputData(string playerNameAr[], int scoreAr[], int &numPlayersRef);
system ("pause");
}
void InputData(string playerNameAr[], int scoreAr[], int &numPlayers)
{
while(numPlayers < 100 & playerNameAr[numPlayers]!= "Q")
{
cout << "Please enter player's name (press Q to quit): ";
getline(cin, playerNameAr[numPlayers], '\n');
cout << endl;
if ((playerNameAr[numPlayers] == "Q") || (playerNameAr[numPlayers] == "q"))
break;
cout << "Please enter " << playerNameAr[numPlayers] << "'s score: ";
cin >> scoreAr[numPlayers];
cout << endl;
cin.ignore(50,'\n');
numPlayers++;
}
}

void DisplayPlayerData(const string playerNameAr[], const int scoreAr[], int numPlayers)
{
cout << fixed << showpoint << setprecision(2);
cout << setw(10) << left << "\n Name"
<< setw(5) << right << "Score" << endl;
for(int i = 0; i < numPlayers; i++)
cout << setw(10) << left << playerNameAr[i] <<(5) << right << scoreAr[i] << endl;
}
double CalculateAverageScore(const int scoreAr[], int numPlayers)
{
int i;
double averageScore,totalScore;
for(i = 0, totalScore = 0; i < numPlayers; i++)
{
totalScore+=scoreAr[i];
}
averageScore = totalScore / i;
cout << "\nAverage Score: " <<averageScore << endl << endl;
return averageScore;
}
void DisplayBelowAverage(const string playerNameAr[], const int scoreAr[], int numPlayers, double averageScore)
{
cout << "Players who scored below average \n";
cout << setw(10) << left << " Name" << setw(5) << right << "Score" << endl;
for(int i = 0; i < numPlayers; i++)
if(scoreAr[i] < averageScore)
cout << setw(10) << left << playerNameAr[i] << setw(5) << right << scoreAr[i] << endl;

}

Last edited on
Firstly: Use code tags
Secondly: Try "moving" (not re posting) to beginners section
Thirdly: we do not do h/w without pay :)
Topic archived. No new replies allowed.