//Giana Osorio CSC5 Chapter 11, p.646, #6
//
/******************************************************************************
*
* CALCULATE SOCCER TEAM TOTAL POINTS
* ___________________________________________________________________________
* This program will accept 12 different soccer players and recieve the players
* number as well as goals scored. Each players name, number, and goals will
* then be displayed. The teams total points will be calulated and displayed
* along with the number and player who scored the most goals.
* ____________________________________________________________________________
* INPUT
* players[] : Holds soccer players information
*
* OUTPUT
* totalGoals : Total Goals the team has made
*****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
//STRUCTURE
struct PlayersInfo
{
string name;
int number;
int goals;
};
int main()
{
const int size = 12; //ARRAY SIZE DECLERATION
PlayersInfo players[size]; //INPUT - Holds soccer players information
int totalGoals = 0; //OUTPUT - Total Goals the team has made
//GET SOCCER PLAYERS INFO
for (int i = 0; i < size; i++)
{
cout << "Please enter a player's name: \n";
cin >> players[i].name;
cout << "Please enter their jersey number: \n";
cin >> players[i].number;
cout << "Please enter the amount of goals they have scored: \n";
cin >> players[i].goals;
//RUNNING TOTAL OF THE TEAMS GOALS
totalGoals += players[i].goals;
}
//DISPLAY TEAM DATA
cout << "PLAYER" << setw(15) << "NUMBER" << setw(15) << "GOALS" << endl;
for (int i = 0; i < size; i++)
{
cout << right << setw(6) << players[i].name << setw(15) << players[i].number
<< setw(15) << players[i].goals << endl;
}
cout << "The team has scored a total of " << totalGoals
<< " goals this season!";
return 0;
}