Question: Please write a c++ code that runs the below program: The text file: 23 Smith C 322 .469 171 95 56 45 Collins 3B 326
Please write a c++ code that runs the below program:




The text file:
23 Smith C 322 .469 171 95 56 45 Collins 3B 326 .202 260 34 32 65 Rodgers OF 223 .247 168 43 12 12 Jennings P 143 .469 76 44 23 42 Flores P 195 .503 97 66 32 17 Clausen 1B 244 .594 99 102 43 6 Marks C 354 .407 210 123 21 7 Hope SS 312 .356 201 88 23 4 Kirk P 122 .205 97 19 6 9 Cooper P 96 .156 81 15 0 0 Holland 2B 266 .211 210 54 2 43 Jackson SS 287 .192 232 32 23 99 Reyes P 132 .492 67 44 21 25 Dawson 3B 212 .198 170 23 19 66 Walker P 121 .289 86 34 1 11 Stein SS 223 .462 120 102 1 21 Rivera OF 342 .307 237 102 3 31 Harvey 1B 312 .468 166 123 23 19 Williams OF 271 .531 127 112 32 3 Jones 2B 332 .497 167 132 33 1 Johnson OF 199 .427 114 73 12 8 Anderson OF 333 .375 208 102 23 68 Jacobson C 213 .442 119 73 21 77 George OF 200 .470 106 74 70 27 Carter 1B 288 .385 177 49 10
Q: Baseball is a sport with constantly changing statistics. Every time a player is at bat, their statistics change. Create a C++ program to control a team's statistics. 1. Import the team's current statistics. To do this, create an array of structures that includes the players NUMBER, NAME, POSITION, AT BATS, BATTING AVERAGE, STRIKEOUTS, ON BASES, and HOMERUNS. Now import the Stats.txt file (DOWNLOAD THIS FILE and store it in your project folder) and write the file contents to the array of structures. The contents of each line of the file is written in the order of the stats above and are separated by a space. 2. Ask the user to enter the current player at bat. Have the user enter the player's number and search the array to find the matching player of structures and output that player's stats. No INPUT VALIDATION IS NEEDED. 3. Ask the user to enter whether the player strikes out, has a base hit, hits a homerun, or gets out. (Assume they enter correctly and no WALKS or ERRORS.) Now adjust the player's stats Batting average (homeruns on base) at bats a. Strike out: at bats 1, strikeouts +-1 b. Base hits: at bats 1, on base 1 c. Homerun: at bats 1, homeruns 1 d. Out: at bats 1 4. Finally, a baseball inning ends after three outs. Make a new file "UpdatedStats.txt" that contains the new states based on what has happened in the inning. Make sure your program can update AT BATS, BATTING AVERAGE, STRIKEOUTS, ON BASES, and HOMERUNS in the Updated Stats.txt file. If the code fails to create or open a file for writing, have the program print an error message "Unable to pen file. New file has not been written
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
