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
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