5 - Basketball, structs, and the string class
purpose of this assignment is to give you practice using structs and
the string class
a file containing team names, their conferences and divisions.
This data will be stored in an array
a file containing scores. Each record in the file must be
to determine the winning and losing team. The number of wins,
losses and percentage must be calculated using the data in the scores
array of structs must be sorted by conference, division, and percentage
to produce output equivalent to that shown below.
- Use the input files, team
name file and scores file. Scores updated 1/1/18 (games
played through 12/31/17)
- Use this struct to store the data for each team:
unsigned short wins;
unsigned short losses;
- Use strings to store all character data for this
assignment. C-strings may not be used
in this assignment.
- The program output must show the current standings using
the team input data and the percentage calculations.
- You may not use stringstream (or istringstream or ostringstream) objects or c-string functions for this assignment.
output should look quite similar to the following. Note: the
actual statistics will be different when you use the current scores
updated 1/1/18 (contains games played through 12/31/17)
Southwest Division W L Pct
Houston Rockets 26 9 0.743
San Antonio Spurs 25 12 0.676
New Orleans Pelicans 18 18 0.500
Dallas Mavericks 13 25 0.342
Memphis Grizzlies 12 25 0.324
Pacific Division W L Pct
Golden State Warriors 29 8 0.784
Los Angeles Clippers 16 19 0.457
Phoenix Suns 14 24 0.368
Sacramento Kings 12 24 0.333
Los Angeles Lakers 11 24 0.314
Northwest Division W L Pct
Minnesota Timberwolves 23 14 0.622
Oklahoma City Thunder 20 17 0.541
Denver Nuggets 19 17 0.528
Portland Trail Blazers 18 17 0.514
16 21 0.432
Southeast Division W L Pct
Washington Wizards 21 16 0.568
Miami Heat 19 17 0.528
Charlotte Hornets 13 23 0.361
Orlando Magic 12 25 0.324
Atlanta Hawks 10 26 0.278
Central Division W L Pct
Cleveland Cavaliers 24 12 0.667
Detroit Pistons 20 15 0.571
Milwaukee Bucks 19 15 0.559
Indiana Pacers 19 18 0.514
Chicago Bulls 13 23 0.361
Atlantic Division W L Pct
Boston Celtics 30 10 0.750
Toronto Raptors 24 10 0.706
New York Knicks 18 18 0.500
Philadelphia 76ers 17 19 0.472
Brooklyn Nets 13 23 0.361
are 30 NBA teams, 15 in each conference. The conferences are
Western and Eastern. There are 6 divisions with 5 teams in each
scores file will also require specific parsing
techniques. Skip over the first line that contains headings.
- To calculate the team percentage, use the formula:
pct = wins / total games played
sort the data for the output standings, you might want to create a
"sortkey" function, consisting of the conference, division, and
percentage. Then you can sort using the "sortkey".
finally, as usual, this assignment contains some subtle aspects.
Be sure to start early and allow enough time to ask the
instructor for help.
- Recommendation, when you start, use a small subset of the
scores file to make sure you are correctly calculating the statistics.