Question: 5-4. Batting Average. Write a program that uses parallel arrays to determine the batting average for a baseball team by position. There are nine positions

5-4. Batting Average. Write a program that uses parallel arrays to determine the batting average for a baseball team by position. There are nine positions on a baseball team and your program should have parallel arrays with an upper bound of 9. Your program will read data in pairs; the first number will be between 1 and 9 and will represent the batters position, and the second number will be either 0 or 1 and will represent an out (0) or a hit (1). The program will continue to input data pairs until the sentinel value 1 is read. At that point, the program should output the batting average for each of the nine positions. (Note: Batting average is the number of hits divided by the number of at bats. Therefore, hits and at bats may be good values to store in parallel arrays.) The output shown below was generated using the input file battingaverage.txt, which may be available from your instructor.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!