[Solved]1 12 Points Baseball Player S Batting Average Calculated Number Hits Divided Official Numb Q37283799

1. (12 points) 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 input containing N, and then N player numbers and batting records. Each player’s record ends with an asterisk. 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 output for each player the input data followed by the batting average. Sample input: 3 12 HO00WSHHOOHPWWHO* 4 OSOHHHWWOHOHO00* 7 WPOHOOHWOHHOWO0* Output: Player 12’s record: HOOOWSHHOOHPWWHO Player 12’s batting average 0.4555 Player 4’s record: OSOHHHWWOHOH000 Player 4’s batting average 0.417 Player 7’s record: WPOH00HWOHHOWOO Player 7’s batting average 0.364 Show transcribed image text 1. (12 points) 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 input containing N, and then N player numbers and batting records. Each player’s record ends with an asterisk. 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 output for each player the input data followed by the batting average. Sample input: 3 12 HO00WSHHOOHPWWHO* 4 OSOHHHWWOHOHO00* 7 WPOHOOHWOHHOWO0* Output: Player 12’s record: HOOOWSHHOOHPWWHO Player 12’s batting average 0.4555 Player 4’s record: OSOHHHWWOHOH000 Player 4’s batting average 0.417 Player 7’s record: WPOH00HWOHHOWOO Player 7’s batting average 0.364
Expert Answer
Answer to 1. (12 points) A baseball player’s batting average is calculated as the number of hits divided by the official number of… . . .
OR

