Question: This is a Baseball Player Statistics program where you will be storing actual data of baseball players using structures and doing operations on them. The
This is a Baseball Player Statistics program where you will be storing actual data of baseball players using structures and doing operations on them. The file baseballdata.txt
has the data of 11 baseball players and multiple attributes related to their statistics. The schema of the data file is reflected in the file baseballdatadescription.txt
: which describes what are the statistics in the data file of the player, and it holds the same for all the players. You will start by creating 3 different structures : a) offense: houses the offensive statistics of the players (Hits, HomeRuns, BattingAverage, Runs, RBI, stolen base, OBP, Slugging, OPS, Silver Slugger Years) b) defense: houses the defensive statistics of the players (Putouts, Assists, Errors, Fielding%, Golden Glove Years) c) player: which nests the offense and defense structures and stores other extra metadata of the players(Name, Position, Bats, Height, Weight, DraftedBy, HallofFame, AllStarGames)
You need to parse the baseballdata.txt file and create an array of players; with all of their statistics loaded from the incoming file. The statistics include various types of primitive data elements such as float, integer, strings, booleans, and arrays. You should be able to determine the appropriate type for appropriate statistics by observing the file. Take the reference of baseballdatadescription.txt and make sure that your players have all of the statistics loaded. (50 pts)
After you create the players array, write the following functions a)printOffensive(offense&) that prints only the offensive statistics of a single player that you pass to the function (10 pts) Sample Output : Offensive: 3465 Hits 260 HR .310 BA 1923 R 1311 RBI 358 SB 377 OBP 440 SLG 0.817 OPS 5 Silver Sluggers b)printDefensive(defense&) that prints only the defensive statistics of a single player that you pass to the function(10 pts) Sample Output: Defensive: 3820 PO 6605 A 254 E 976% Fld 5 Golden Gloves c)printPlayer(player&) that calls printOffensive and printDefensive functions , alongside extra player data to print the entire statistics of the player, represented as a Player Card in the following form: (50 pts) An example player card looks like so : ( You should call printDefensive and printOffensive functions defined above )

For the subsequent operations, you will be printing a similar type of Player Card as a result of search/sort operations.
d) create a function searchByName(string) that asks the user for the first name of the player and prints the Player Card (similar to the visual format of Section c) (30 pts) e) Print the Player Card of all the players who are in the Hall of Fame ( * in the data file represents Not eligible for HOF, elsewise any other player is HOF ) (20 pts) f) Export the player Card of the people whose WAR value is greater than 70 into the file war_70.txt (Similar to printing the player cards to the console, but this time you need to print them in the file ) (30 pts) g) Export the player Card of the people who had more than 100 Stolen Bases into the file stolenbase_100.txt (Similar to printing the player cards to the console, but this time you need to print them in the file ) (30 pts) Bonus : g) Sort the players by their WAR value and print the top 3 players by their WAR. (80 pts) h) Export the player Card of all the players who won the Silver Slugger and Golden Glove award in the same year(s) at least one (At least 1 common item in the Silver Slugger Years array and the golden glove years) (50 pts)
###################################################################################################3
This is baseballdata.txt
Player
Derek Jeter
Shortstop
Right
190
88
New York Yankees
HOF
14
72.4
Offense
3465
260
310
1923
1311
358
377
440
0.817
2006 2007 2008 2009 2012
Defense
3820
6605
254
976
2004 2005 2006 2009 2010
Player
Mike Trout
Centerfielder
Right
188
106
Los Angeles Angels
*
8
72.5
Offense
1324
285
305
903
752
200
419
581
1.000
2012 2013 2014 2015 2016 2018 2019
Defense
2768
38
20
993
*
Player
Miguel Carbera
First Baseman
Right
193
112
Detroit Tigers
*
11
69.6
Offense
2815
477
315
1429
1694
38
392
543
0.935
2005 2006 2010 2012 2013 2015 2016
69.6
Defense
10136
1858
152
987
*
Player
Ken Griffey Jr
Centerfielder
Left
190
88
Seattle Mariners
HOF
13
83.8
Offense
2781
630
284
1662
1836
184
370
538
0.907
1991 1993 1994 1996 1997 1998 1999
Defense
5607
154
89
985
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
Player
Yadier Molina
Catcher
Right
180
92
St Louis Cardinals
*
9
40.2
Offense
1963
156
282
701
916
66
333
405
0.738
2013
Defense
13540
983
75
995
2008 2009 2010 2011 2012 2013 2014 2015 2018
Player
Buster Posey
Catcher
Right
185
95
San Francisco Giants
*
6
Offense
1963
156
282
701
916
66
333
405
0.738
2013
Defense
9035
623
50
995
2016
Player
Carlos Beltran
Centerfielder
185
97
Kansas City Royals
*
9
Offense
2725
435
279
1582
1587
312
350
486
0.837
2006 2007
Defense
5158
143
75
986
2006 2007 2008
Player
Larry Walker
RightFielder
Left
188
83
Montreal Expos
HOF
5
Offense
2160
383
313
1355
1311
230
400
565
965
1992 1997 1999
Defense
3976
213
57
987
1992 1993 1997 1998 1999 2001 2002
Player
Edgar Martinez
Designated Hitter
Right
183
79
Seattle Mariners
HOF
7
Offense
2247
309
312
1219
1261
49
418
515
0.933
1992 1995 1997 2001 2003
Defense
566
1025
81
952
*
Player
Barry Bonds
LeftFielder
Left
185
83
San Francisco Giants
*
14
Offense
2935
762
298
2227
1996
514
444
607
1.051
1990 1991 1992 1993 1994 1996 1997 2000 2001 2002 2003 2004
Defense
5637
173
97
984
1990 1991 1992 1993 1994 1996 1997 1998
Player
Hank Aaron
RightFielder
Right
183
81
Atlanta Braves
HOF
25
Offense
3771
755
305
2174
2297
240
374
555
0.928
*
Defense
7436
429
144
982
1958 1959 1960
end of baseballdata.txt
####################################################################################
THIS IS BASEBALLDATADESCRIPTION.TXT
Player(Marker to indicate a new player data )
NameofPlayer
Position
Bats : Left/Right
Height (cm)
Weight (kg)
Drafted By Team Name
HallofFame * (HOF signifies player is a Hall of Famer , * means he is not
a Hall of Famer)
AllStarGames ( Number of All Star Games Player has played in )
WAR ( Wins Above Replacement of a player )
--Offense
Hits
HomeRuns
BattingAverage
Runs
RBI (Runs Batted In)
Stolen Base
OneBasePercentage (OBP)
Slugging
OPS (OneBasePercentage + Slugging)
Silver Sluger Years (Array of years in which the player won silver slugger
award)
--Defense
Putouts
Assists
Errors
Fielding %
Golden Gloves Years (Array of years in which the player won golden gloves
award)
END OF BASEBALLDATADESCRIPTION.TXT
Transcribed image text
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
