# CS215 Programming Assignment 1 Most Valuable Player solution

\$30.00

Original Work ?

## 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\$
Description:
calculate\$shooting\$percentages\$and\$points\$per\$48\$minutes\$and\$output\$the\$data\$on\$the\$
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:
getPlayer:
Top\$Offensive\$Player:
23\$Michael\$Jordan\$
Top\$Defensive\$Player:
6\$Bill\$Russell
Most\$Valuable\$Player:
33\$Kareem\$AbdulDJabaar
Player\$Name\$\$\$\$\$\$\$\$\$\$\$Min\$\$FGA\$FGM\$\$PCT\$3PA\$3PM\$\$PCT\$FTA\$FTM\$\$PCT\$OFF\$DEF\$TOT\$STL\$BLK\$AST\$\$TO\$\$PF\$\$PTS\$\$P48
AbdulDJabaar,\$Kareem\$\$321\$\$162\$\$81\$.500\$\$\$0\$\$\$0\$\$DDD\$\$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)
Three\$Point\$Attempts\$(3pt\$shots\$attempted\$–\$included\$in\$fga)
Free\$Throw\$attempts\$(number\$of\$foul\$shots\$taken)
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\$
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: