//Written by Mark Lair

//November 12, 2007

//Chapter 11

//Assignment: Team Player

// this program will calculate and display
// the points scored by each member of a team
// and the total points by the team

#include <iostream>
#include <iomanip>
using namespace std;

const int SIZE = 25; //char array size


struct PlayerInfo
{
	int plNum;		//player number
	char plName[SIZE];	//player name
	int plPoints;	//points scored by player
};

// Function Prototypes

int main()
{

	const int NUM_PLAYERS = 5;	//number of players
	PlayerInfo players[NUM_PLAYERS];	//array of structures
	int index;	//loop counter
	int total = 0; //total number of points for the team


	//get player data
	cout << "Enter the Numbers, Names, and points scored by each of the " << NUM_PLAYERS
		 << " on the team.\n";

	for (index = 0; index < NUM_PLAYERS; index++)
	{
		//Get player's jersey number
		cout << "Enter the 2 digit jersey number for player #" << (index + 1);
		cout << ": ";
		cin >> players[index].plNum;

		//Get player's name
		cout << "Now enter that player's name: ";
		cin.ignore();
		cin.getline(players[index].plName, SIZE);

		//Get player's points
		cout << "How many points did that player score? ";
		cin >> players[index].plPoints;
		cout << endl;

		total += players[index].plPoints;
	}

	
	//Display each player's number, name and points and the total points for the team
	cout << "Here is a table of each player's number, name and points:\n";
	cout << endl;
	cout << "    #   " << left << setw(25) << "Player's Name" << right << setw(3) << " Points\n";
	for (index = 0; index < NUM_PLAYERS; index++)
	{
		cout << " +--------------------------------------+ \n";
		cout << " + " << setw(2) << players[index].plNum << " + " << left << setw(25) << players[index].plName;
		cout << " + " << right << setw(3) << players[index].plPoints << " + \n";
		cout << " +--------------------------------------+ \n";

	}

	cout << endl;
	cout << "The total number of points scored by the team was: " << total << "." << endl;

			
			
		system("pause");			
			
		return 0;
}
