//Jonathan Estrada CSC5 Chapter 11, P.646, #6
/*******************************************************************************
* GET TEAM STATS
* _____________________________________________________________________________
* This program gets jerasy numbers, name, and points scored, then displays the
* information on a table. The program will also display the player who scored
* the most points and the total points for the team.
* _____________________________________________________________________________
* INPUT
* size : size of team
* playerName : player name
* playerNum : player jerasy number
* points : points scired
*
* OUTPUT
* totalPoints : total points of team
* maxindex : player with the most individual points scored
*
* ****************************************************************************/
#include <iostream>
#include <string>
using namespace std;
struct team
{
string playerName;
int playerNum;
int points;
};
int main() {
int size = 11;
int totalPoints = 0;
int maxPoints = 0, maxindex = 0;
team player[size];
for(int i= 0; i < size; i++)
{
cout << "Player Name: ";
getline(cin, player[i].playerName);
cout << "Player Number: ";
cin >> player[i].playerNum;
cin.ignore();
cout << "Player Points: ";
cin >> player[i].points;
while(player[i] > 0)
{
cout << "Invalid cannot be less than 0." << endl;
cout << "Player Points: ";
cin >> player[i].points;
}
cin.ignore();
totalPoints += player[i].points;
if(player[i].points > maxPoints)
{
maxPoints = player[i].points;
maxindex = i;
}
}
cout << "Players Information for the Team" << endl;
cout << "Number " << " Name " << " Points" << endl;
cout << "--------------------------------" << endl;
for(int i= 0; i < size; i++)
{
cout << player[i].playerNum << "|" << player[i].playerName << "|"
<< player[i].points << endl;
}
cout << "Total points for every player is " << totalPoints << endl;
cout << "\nPlayer with the most points was: " << endl;
cout << player[maxindex].playerNum << "|" << player[maxindex].playerName << "|"
<< player[maxindex].points << endl;
return 0;
}