Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A baseball player\'s batting average is calculated as the number of hits divided

ID: 3656193 • Letter: A

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, 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. The following example shows the format of the input file and its corresponding output. Sample data: 12 HOOOWSHHOOHPWWHO 4 OSOHHHWWOHOHOOO 7 WPOHOOHWOHHOWOO Corresponding output: 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

Explanation / Answer

//not sure how the hit average is calculated...so formula needs fixing #include #include #include #include using namespace std; struct player{ int number; string record; double average; }; void getavgs(player team[],int count); void printavgs(player team[], int peoplecount); int main(){ player team[18];//max of 18 players int peoplecount=0; int temp; ifstream infile; string filename; do{ coutfilename; if(filename=="-1"){ cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote