In: Computer Science
Instructions: program in C++, add pseudocode and comment throughout the program.
Assignment:
Create a program to keep track of the statistics for a kid’s soccer team. The program will have a structure that defines what data the program will collect for each of the players.
The structure will keep the following data:
The program will have an array of 12 players (use less for testing and development, use a constant for the size). Each element in the array is a different player on the team.
The program will ask the user to enter information for each player. The program will also display the team information in a table format. After the table, the total points scored by a team will be displayed.
The program will also determine which player scored the most points on the team.
Validation:
Required Methods:
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;
struct Player
{
string name;
int jerseyNum;
int points;
};
void GetPlayerInfo(Player &p);
void ShowPlayerInfo(const Player p);
int GetTotalPoints(const Player p[], int size);
void ShowHighest(Player p[], int size);
int main() {
const int SIZE=12;
Player p[SIZE];
for(int i=0;i<SIZE;i++)
{
cout<<"Player"<<(i+1)<<"::"<<endl;
GetPlayerInfo(p[i]);
cin.ignore();
}
for(int i=0;i<SIZE;i++)
{
ShowPlayerInfo(p[i]);
}
int tot=GetTotalPoints(p,SIZE);
cout<<"Total Points :"<<tot<<endl;
ShowHighest(p,SIZE);
return 0;
}
void GetPlayerInfo(Player &p)
{
cout<<"Enter name :";
getline(cin,p.name);
while(true)
{
cout<<"Enter jersey
number :";
cin>>p.jerseyNum;
if(p.jerseyNum<0)
{
cout<<"** Invalid.Must
be positive **"<<endl;
}
else
break;
}
while(true)
{
cout<<"Enter points
:";
cin>>p.points;
if(p.points<0)
{
cout<<"** Invalid.Must
be positive **"<<endl;
}
else
break;
}
}
void ShowPlayerInfo(const Player p)
{
cout<<setw(15)<<left<<p.name<<setw(6)<<right<<p.jerseyNum<<setw(6)<<right<<p.points<<endl;
}
int GetTotalPoints(const Player p[], int size)
{
int tot=0;
for(int i=0;i<size;i++)
{
tot+=p[i].points;
}
}
void ShowHighest(Player p[], int size)
{
int max=p[0].points;
int maxIndx=0;
for(int i=0;i<size;i++)
{
if(max<p[i].points)
{
max=p[i].points;
maxIndx=i;
}
}
cout<<"Highest Points "<<max<<" is
earned by "<<p[maxIndx].name<<endl;
}
____________________________
Output:
_______________Could you plz rate me well.Thank
You