5 - Basketball, structs, and the string class
due Saturday, February 17th
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 2/5/18 (games
played through 2/4/18)
- 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 2/5/18 (contains games played through 2/4/18)
Southwest Division W L Pct
Houston Rockets 38 13 0.745
San Antonio Spurs 34 21 0.618
New Orleans Pelicans 28 24 0.538
Memphis Grizzlies 18 34 0.346
Dallas Mavericks 17 36 0.321
Pacific Division W L Pct
Golden State Warriors 41 12 0.774
Los Angeles Clippers 26 25 0.510
Los Angeles Lakers 21 31 0.404
Phoenix Suns 18 36 0.333
Sacramento Kings 16 36 0.308
Northwest Division W L Pct
Minnesota Timberwolves 34 22 0.607
Oklahoma City Thunder 30 24 0.556
Portland Trail Blazers 29 24 0.547
Denver Nuggets 28 25 0.528
24 28 0.462
Southeast Division W L Pct
Washington Wizards 30 22 0.577
Miami Heat 29 24 0.547
Charlotte Hornets 23 29 0.442
Atlanta Hawks 16 37 0.302
Orlando Magic 15 36 0.294
Central Division W L Pct
Cleveland Cavaliers 30 21 0.588
Milwaukee Bucks 29 23 0.558
Indiana Pacers 30 24 0.556
Detroit Pistons 25 26 0.490
Chicago Bulls 18 34 0.346
Atlantic Division W L Pct
Boston Celtics 39 15 0.722
Toronto Raptors 36 16 0.692
Philadelphia 76ers 25 25 0.500
New York Knicks 23 31 0.426
Brooklyn Nets 19 35 0.352
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.