Question: C Programming 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,

C Programming

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, and P-hit by pitch. The program should output for each player the input data followed by the batting average.

Data file would be similar to example below. Each new record is in new line and each line contains id of the player followed by his batting record:

13 OOHPS

2 OHOHOHOH

31 WHOPWHOP

PlEASE USE THIS SAMPLE RUN Below:

Enter data file name: dat

Player 12's record: HOOOWSHHOOHPWWHOPOH

Player 12's batting average: 0.462

Player 4's record: OSOHHHWWOHOHOOOOOH

Player 4's batting average: 0.400

Player 7's record: WPOHOOHWOHHOWOOOHOP

Player 7's batting average: 0.357

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!