Baseball Batting averages

Computer Science 1

Programming Assignment 5


90 Points

Baseball Batting Averages

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 for 20 players. 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 read the input file and store the player number and corresponding batting average into two parallel arrays. Print the player numbers and corresponding averages. Then sort the batting average array into ascending order using either the selection sort or bubble sort algorithm and print the sorted array. Calculate and print the average, median, and mode for the batting average array, using a frequency array to find the average.

The input file is in the format shown below. A sample input data file is located in D2L under Content for Unit 7. (Hint: Each batting record is followed by a newline character.)

Sample input file:




Data Validation: If the batting code read from the data file is not ‘W’, ‘H’, O’, or ‘S’, the program should print a message and not include that particular code in the batting average.

Use separate functions to:

1. Read the data and find the batting averages.

2. Print the player numbers and batting averages.

3. Sort the averages.

4. Print the sorted averages.

5. Calculate the mean (average) of the batting averages.

6. Calculate the median of the batting averages.

7. Build the frequency array.

8. Calculate the mode of the batting averages.

9. Print the mean, median, and mode for the batting average array.

Design your program by completing the CS 150 Program Design Document. Be sure to include a structure chart for the program, the prototype for each function, and a brief description of each function’s purpose.

Save the design in a file named [url removed, login to view] where xxx are your initials and submit it in the Program 7 Design drop box by the date shown in the calendar – this is before the program due date.

Code your program. Save it in a file named [url removed, login to view] where xxx are your initials.

Compile, run and test your program.

Submit your working .cpp file in the Program 7 dropbox by the date shown in the calendar and drop box tools.

Beceriler: C Programlama

Daha fazlasını gör: write program batting average, programming baseball program, use array program baseball averages, write program calculate batting average, program calculate average baseball bats file, calculating players batting average programming, batting average program, baseball parallel array, w 9 purpose, use of data structure in programming, unit test order, tools of computer programming, tools for computer programming, the science of programming, sort function c, sort bubble, sort array in ascending order in c, sort array c, sort algorithm, science algorithm, purpose of w-9, prototype validation, prototype chart, programming loops, programming and computer science

İşveren Hakkında:
( 1 değerlendirme ) United States

Proje NO: #4458158



Kindly check your inbox. Thanks

%selectedBids___i_period_sub_7% gün içinde 94%project_currencyDetails_sign_sub_9% %project_currencyDetails_code_sub_10%
(22 Değerlendirme)

Bu iş için 3 freelancer ortalamada $145 teklif veriyor


Expert Solution here. Check PM

in %bids___i_period_sub_35% gün içinde242%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(3 Değerlendirme)

We can do this for you.

in %bids___i_period_sub_35% gün içinde100%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(0 Değerlendirme)