Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago