Hi I am currently taking a Comp Sci class, its a non major course in programming in C + + , but I have found the course to be very difficult. I have to write a program by friday which will pretty much be the determining factor as to wether I pass or fail the course. Can anyone please help me with it. Any help will be greatly appreciated. Thanks in advance.
Here is the program:
The local baseball team is computerizing its records. You are to write a program that computes batting averages. There are 20 players in the team, identified by the numbers 1 to 20. Their batting records are coded in a file score.txt as follows. Each line contains 4 numbers: the player's identification number and the number of hits, walks and outs he or she made in a particular game. Here is a sample:
3 2 1 4
4 3 2 2
5 4 1 7
3 5 1 0
The example above contains 5 records. The first record indicates that during a game, player number 3 was at bat 4 times and made 2 hits, one walk, and one out. For each player there are several lines in the file. Each player's batting average is computed by adding the total number of hits and and dividing by the total number of times at bat. A walk does not count as either a hit or a time at bat when the batting average is being calculated.
For the sample shown above, player 3's total number of hits is 2 + 5 = 7 and the total number of times at bat is 2 + 4 + 5 + 0 = 11. Therefore, player 3's batting average is 7/11 = 0.64.
Your program prints a table showing each player's identification number, batting average, and number of walks. (Be careful: The player's identification numbers are 1 through 20, but C++ array indexes start at 0.)
Use a function to compute a player's batting average.
Use a structure to represent player information including at least the identification number, batting average, and number of walks. You may include other information in the structure to calulate batting averages etc. Use an array of such structures to represent the baseball team.