Two important stats in baseball are the team batting average and the team slugging average. Batting average is defined as the total number of hits (this includes base hits, base hits, base hits and home runs combined) divided by the total number of times at bat ("at bats") for all players on the team. The team slugging average is defined using the following equation:
Where is the number of base hits, is base hits, is base hits, is home runs, and is the number of at bats for all players on the team. Both slugging and batting averages are always presented as decimals rounded to places, leaving off the leading (in theory batting averages can be as high as , and slugging averages as high as but in practice they are both usually well below ).
The input contains the raw data on the top teams during a regular season of Major League Baseball. The first line is the season name, followed by lines for each of the top teams. Each of these lines starts with a team name (single word) followed by integers: Games Played, At Bats, Runs, Hits (total), two-base hits, three-base hits, and home runs. One space character separates each item on each line.
Write a program to produce a report showing the batting and slugging averages for each team in the order they appeared in the input file, and formatted EXACTLY as shown below, including all punctuation and matching upper and lower case exactly. All spacing is done with a single space character. All batting and slugging averages will be less than . The final line shows the same averages for all teams combined (computed from the sum of all at bats, hits, etc. for all teams). Note that the two lines of =
characters each contain characters.
Sample Input
2011 Regular Season
Boston 162 5710 875 1600 352 35 203
NY_Yankees 162 5518 867 1452 267 33 222
Texas 162 5659 855 1599 310 32 210
Detroit 162 5563 787 1540 297 34 169
St.Louis 162 5532 762 1513 308 22 162
Toronto 162 5559 743 1384 285 34 186
Cincinnati 162 5612 735 1438 264 19 183
Colorado 162 5544 735 1429 274 40 163
Arizona 162 5421 731 1357 293 37 172
Kansas_City 162 5672 730 1560 325 41 129
Sample Output
2011 Regular Season
====================
Boston: .280 .461
NY_Yankees: .263 .444
Texas: .283 .460
Detroit: .277 .434
St.Louis: .273 .425
Toronto: .249 .413
Cincinnati: .256 .408
Colorado: .258 .410
Arizona: .250 .413
Kansas_City: .275 .415
====================
Big 10 Av: .267 .428
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments