///Can someone tell me why I am having an issue calling my functions?!?!?!
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct Players
{
string name;
int numPlayer; //Number of the Player
int numPoints; //Point's scored by Player
};
const int SIZE = 50;
const int MAXPLAYERS =3;
typedef struct Players Roster[12];
int total;
int maxgoals = 0;
void Greeting ();
void TotalPoints (Roster &Players);
void HighestScore (Roster &Players);
void DisplayAll (Roster &Players);
int main ()
{
Roster SoccerPlayers;
Greeting();
for (int index=0; index< 2; index++) // put this in a function
{
cout << "Player's Name:";
getline(cin, SoccerPlayers[index].name);
do
{
cout << "Uniform Number:";
cin >> (SoccerPlayers[index].numPlayer);
if (SoccerPlayers[index].numPlayer<=0)
cout << "Invalid entry, Please re-enter:" << endl;
}while (SoccerPlayers[index].numPlayer<=0);
do
{
cout << "Points Scored:";
(cin >> SoccerPlayers[index].numPoints).get();
if (SoccerPlayers[index].numPoints<=0)
cout << "Invalid entry, Please re-enter:" << endl;
}while (SoccerPlayers[index].numPoints<=0);
}
DisplayAll(Players);
TotalPoints(Players);
HighestScore(Players);
return 0;
}
void Greeting ()
{
cout << "___________________________________________________" << endl;
cout << "Welcome to the Soccer Team Data Analyzer" << endl;
cout << "You will now be asked to enter the name" << endl;
cout << "uniform number, and points earned for each player." << endl;
cout << "___________________________________________________" << endl;
}
void DisplayAll (Roster &SoccerPlayers)
{
cout << "Players Score Summary" << endl << endl;
cout << "_________________________" <<endl;
cout << "Name Number Score" << endl;
cout << "_________________________" << endl;
for (int index=0; index< MAXPLAYERS; index++)
{
cout << setw(20) <<left << SoccerPlayers[index].name;
cout << setw(15) <<left << SoccerPlayers[index].numPlayer;
cout << SoccerPlayers[index].numPoints;
}
}
void TotalPoints (Roster &SoccerPlayers)
{
int TotalScore = 0;
for (int index = 0; index < 2; index++)
{
TotalScore += (SoccerPlayers[index].numPoints);
}
}
void HighestScore (Roster &SoccerPlayers)
{
int max = SoccerPlayers[0].numPoints;
int maxIndex = 0;
for (int index = 0; index < 2; index++)
{
if (SoccerPlayers[index].numPoints > max)
{
max = SoccerPlayers[index].numPoints;
maxIndex = index;
}
}
}