Question
C++ Programming You are to develop a program to read Baseball player statistics from an input file. Each player should bestored in a Player object.
C++ Programming
You are to develop a program to read Baseball player statistics from an input file. Each player should bestored in a Player object. Therefore, you need to define the Player class. Each player will have a firstname, last name, a position (strings) and a batting average (floating point number). Your class needs to provide all the methods needed to read, write, initialize the object. Your data needs to be stored in an array of player objects. The maximum size of the array should be 50for this version of the program. Make sure that you 1) keep track of how many players have beenstored in the array and, 2) you do not overwrite the end of the array if there happens to be more than50 players in the data file. An input data file will be used to provide the data. Each player is written in the file, one per line, in thefollowing form FIRSTNAME LASTNAME POSITION BATTINGAVERAGE Note that the data is separated by blanks only. There are no commas or other separator characters inthe input data. You will need to create your own file for testing.
Summary of Operation Prompt the user for the input and output file names. DO NOT hardcode file names into yourprogram.
Open input file
Read each player and store them in an array of Player objects
Keep track of the number of players in the array
Open an output file
Write each player from the array into the output file, along with any other output required bythe assignment.
Remember to close your files when done with them
Make sure to use detailed comments
Example Input:
Chipper Jones 3B 0.303
Rafael Furcal SS 0.281
Hank Aaron RF 0.305
Example Output:
There were 3 players in the input data file:
Jones, Chipper: 3B (0.303)
Furcal, Rafael: SS (0.281)
Aaron, Hank: RF (0.305)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started