Question: A baseball player's batting average is calculated as the number of hits divided by the official number of at-bats. In calculating official at-bats, walks, sacrifices,

A baseball player's batting average is calculated as the number of hits divided by the official number of at-bats. In calculating official at-bats, walks, sacrifices, and occasions when hit by the pitch are not counted. Write a program that takes an input file containing player numbers and batting records. Trips to the plate are coded in the batting record as follows: H--hit, O--out, W--walk, S--sacrifice, P--hit by pitch. The program should calculate each player's batting average.

(You will use argv[1] as name of file in fopen() function call.) Example: 12 HOOOWSHHOOHPWWHO

4 OSOHHHWWOHOHOOO

7 WPOHOOHWOHHOWOO

Player 12's record: HOOOWSHHOOHPWWHO

Player 12's batting average: 0.455

Player 4's record: OSOHHHWWOHOHOOO

Player 4's batting average: 0.417

Player 7's record: WPOHOOHWOHHOWOO

Player 7's batting average: 0.364

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!