Description
Overview:
The learning objective of this project is for you to understand the purpose of parallel
vectors and how to use them. In this assignment you will use the program that you wrote
for the Lab Week 3 assignment in order to design and create data structures using parallel
vectors to hold the data that was read in from the file and then process those vectors.
Description:
Just like in Lab Week 3, this program will read statistical data for basketball players,
calculate shooting percentages and points per 48 minutes and output the data on the
console. In addition to this processing you will add three additional functions to your
programs:
void findTopOffensivePlayer()
This function will find and output the name of the player who has the highest
offensive rating using the formula:
Offensive Rating = Points per 48 + (Offensive Rebounds per 48 * .4) + (Assists per 48
* .4) – (Turnovers per 48 * .4)
void findTopDefensivePlayer()
This function will find and output the name of the player who has the highest
defensive rating using the formula:
Defensive Rating = (Defensive Rebounds per 48 * .4) + (Blocked Shots per 48 * .4) –
(Steals per 48 * .4) – Personal Fouls per 48
void findMostValuablePlayer()
This function will find and output the name of the player who has the highest MVP
rating using the formula:
MVP Rating = (Defensive Rating * .67) + (Offensive Rating * .33)
Your output for this program will be the same:
With the following additional lines:
The same four functions you were given for file reading will remain the same.
getPlayer:
Top Offensive Player:
23 Michael Jordan
Top Defensive Player:
6 Bill Russell
Most Valuable Player:
33 Kareem Abdul-‐Jabaar
Player Name Min FGA FGM PCT 3PA 3PM PCT FTA FTM PCT OFF DEF TOT STL BLK AST TO PF PTS P48
Abdul-‐Jabaar, Kareem 321 162 81 .500 0 0 -‐-‐-‐ 40 32 .800 32 49 81 0 16 5 2 32 194 29.0
…
TOTAL 1920 810 341 .421 37 12 .324 192 133 .693 164 381 545 37 39 118 195 243 826 20.7
This function will populate variables to hold the values for:
Player’s uniform number
Player’s first name
Player’s last name
Minutes played
getShooting:
This function will populate variables to hold the values for the players’ shooting
statistics:
bool getPlayer(int& num, string& first, string& last, int& min)
{
if(!infile.isOpen())
{
infile.open(“lab3.dat”);
}
infile >> num;
if(infile.eof())
{
infile.close();
return false;
} else
{
assert(!infile.fail());
}
infile >> first;
assert(!infile.fail());
infile >> last;
assert(!infile.fail());
infile >> min;
assert(!infile.fail());
return true;
}
Field goal attempts (number of shots taken)
Field goals made (number of baskets made)
Three Point Attempts (3pt shots attempted – included in fga)
Three Pointers Made (3pt baskets made – include in fgm)
Free Throw attempts (number of foul shots taken)
Free Throws Made (number of foul shots made)
getRebounds:
void getShooting(int& fga, int& fgm, int& tpa, int& tpm, int& fta, int& ftm)
{
infile >> fga;
assert(!infile.fail());
infile >> fgm;
assert(!infile.fail());
infile >> tpa;
assert(!infile.fail());
infile >> tpm;
assert(!infile.fail());
infile >> fta;
assert(!infile.fail());
infile >> ftm;
assert(!infile.fail());
return;
}
This function will populate variables to hold the values for the players’ rebounding
statistics:
Offensive rebounds (rebounds of team’s missed shots)
Defensive rebounds (rebounds of opponents missed shots)
getOthers:
This function will populate variables to hold the values for miscellaneous players’
statistics:
Steals (number of times a player forced an opponent turnover)
Blocked Shots
Assists (number of times a player’s pass resulted in a basket)
Turnovers
Personal Fouls
void getRebounds(int& off, int& def)
{
infile >> off;
assert(!infile.fail());
infile >> def;
assert(!infile.fail());
return;
}
void getOthers(int& stl, int& blk, int& ast, int& to, int& pf)
{
infile >> stl;
assert(!infile.fail());
infile >> blk;
assert(!infile.fail());
infile >> ast;
assert(!infile.fail());
infile >> to;
assert(!infile.fail());
infile >> pf;
assert(!infile.fail());
return;
}
Calculations:
Field Goal % = Field Goals Made / Field Goals Attempted
Three Point % = Three Pointers Made / Three Pointers Attempts
Free Throw % = Free Throws Made / Free Throws Attempted
Totals Rebounds = Offensive Rebounds + Defensive Rebounds
Points = (2 * Field Goals Made) + Three Pointers Made + Free Throws Made
Points Per 48 = Points / (Minutes Played / 48)
Offensive Rebounds Per 48 = Offensive Rebounds / (Minutes Played / 48)
Defensive Rebounds Per 48 = Defensive Rebounds / (Minutes Played / 48)
Assists Per 48 = Assists / (Minutes Played / 48)
Turnovers Per 48 = Turnovers / (Minutes Played / 48)
Steals Per 48 = Steals / (Minutes Played / 48)
Personal Fouls Per 48 = Personal Fouls / (Minutes Played / 48)
Blocked Shots Per 48 = Blocked Shots / (Minutes Played / 48)
Put your program in a .zip file and upload it to the CS Portal.

