Assignment
5 - Football, structs, and the string class
due Tuesday, 10/27
The
purpose of this assignment is to give you practice using structs and
the string class.
Program Steps
-
Read a file containing team names, their conferences and divisions.
This data will be stored in an array of structs.
-
Read a file containing scores. Each record in the file must
be parsed to determine the winning and losing team. The
number of wins, losses and percentage must be calculated using
the data in the scores file.
-
The array of structs must be sorted by conference, division, and
percentage to produce output equivalent to that shown below.
Program Requirements
- Use the input files, team
name file and scores
file. The scores
file will be updated again at a later date.
- Use this struct to store the data for each team:
struct NFL_Team
{
string name;
string conference;
string division;
unsigned short wins;
unsigned short losses;
unsigned short ties;
};
- Use strings to store all character data for 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.
Program Output
Your output should look quite similar to the following.
Note: the actual statistics will be different when you use
the current scores file.
Games through 10/19/20
American Football Conference
East
Division
W L
T Pct Buffalo
Bills
4 2 0 0.667 Miami
Dolphins
3 3 0 0.500 New England Patriots 2 3 0 0.400 New
York
Jets
0 6 0 0.000
North
Division
W L
T Pct Pittsburgh
Steelers
5 0 0 1.000 Baltimore
Ravens
5 1 0 0.833 Cleveland
Browns
4 2 0 0.667 Cincinnati
Bengals
1 4 1 0.250
South
Division
W L
T Pct Tennessee
Titans
5 0 0 1.000 Indianapolis
Colts
4 2 0 0.667 Jacksonville Jaguars 1 5 0 0.167 Houston
Texans
1 5 0 0.167
West
Division
W L
T Pct Kansas
City Chiefs
5 1 0 0.833 Las
Vegas Raiders
3 2 0 0.600 Denver
Broncos
2 3 0 0.400 Los Angeles Chargers 1 4 0 0.200
National Football Conference
East
Division
W L
T Pct Dallas
Cowboys
2 4 0 0.333 Philadelphia
Eagles
1 4 1 0.250 New
York
Giants
1 5 0 0.167 Washington Football Team 1 5 0 0.167
North
Division
W L
T Pct Chicago
Bears
5 1 0 0.833 Green
Bay Packers
4 1 0 0.800 Detroit
Lions
2 3 0 0.400 Minnesota
Vikings
1 5 0 0.167
South
Division
W L
T Pct Tampa Bay Buccaneers 4 2 0 0.667 New
Orleans Saints
3 2 0 0.600 Carolina
Panthers
3 3 0 0.500 Atlanta
Falcons
1 5 0 0.167
West
Division
W L
T Pct Seattle
Seahawks
5 0 0 1.000 Los
Angeles
Rams
4 2 0 0.667 Arizona
Cardinals
4 2 0 0.667 San
Francisco 49ers
3 3 0 0.500
|
Program Notes
- There are 32 NFL teams, 16 in each conference.
The
conferences are American and National. There are 8 divisions with 4
teams in each division.
- The scores file will also require specific parsing
techniques. Skip over the date column. To parse a
scores record, use string functions looking for a comma. It
will be handy to write a function that can pick out a team name from a
text String. The string find() and rfind() functions will be
useful here.
- To calculate the team percentage, use the formula:
percent = (wins + 0.5 * ties) / total games played
- To 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".
- And 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.
- Be sure your code handles ties. There may be
one/some in the test file used to grade your assignment.
Hints