It's baseball season again! Our next project centers around one way to statistically analyze starting pitchers

The Society of American Baseball Research (SABR) is a group of baseball fans, writers, historians, and other researchers. The members of SABR are intensely interested in and study all facets of the game. They have created Sabermetrics, which is the mathematical and statistical analysis of baseball records. One of the many topics studied by sabermetricians is pitching statistics and how to create ones that are more meaningful measures to use in the comparison of pitchers, both past and present.

One statistic that is used in the evaluation of starting pitchers is Game Score, developed by sabermetrics pioneer Bill James. (A modified version of Game Score was published by Tom Tango in 2016.) The original method for calculating the Game Score for a particular game is:

  • Begin with 50 points.
  • Add one point for every out recorded; thus, three points for every complete inning pitched.
  • Add two points for each full inning completed after the fourth (on top of the points above).
  • Add one point for every strikeout (K).
  • Subtract two points for every hit allowed.
  • Subtract four points for every earned run allowed.
  • Subtract two points for every unearned run allowed.
  • Subtract one point for each walk (BB).

You have been asked to write a program that will, for a group of pitchers, calculate the Game Score for every game of each pitcher's season, along with that pitchers average Game Score. Your program will be processing a text file that contains the following information for each pitcher:

1st line: Name (25 characters, padded with blanks on the right), and Season (year) (an integer in columns 26-29).

Subsequent lines (one line per game): Innings Pitched (IP), Hits Allowed (H), Runs Allowed (R), Earned Runs Allowed (ER), Walks (BB), and Strikeouts (K).

You must create a data file (as described above and discussed in class) in order to test your program. Sample data (first few lines for Max Scherzer's 2017 season):

Max Scherzer 2017
6.2 4 2 2 2 7
6.0 4 3 1 2 10

Note that a different data file will be used to test your program.

Write a program that will process the data in such a file and will display (on screen) each pitcher's Name and the season, followed by the Game Score for each game started by the pitcher (one Game Score per line). At the end of a pitcher's data, the number of games started by that pitcher and the pitchers Average Game Score should be displayed. Show the Average Game Score to two decimal places (nearest hundredth).

Sample output (for the sample data shown above):

Max Scherzer 2017
Game Scores:
63
64
Number of Games Started: 2
Average Game Score: 63.50

You should make efficient use of functions in this program.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.