Programming Assignment 16

 

 

The local baseball team is called the Oneonta Otters and has 10 players.  They are computer­izing their records and have hired you to write a program that computes batting averages and on-base averages.  Their batting records are recorded in a file as follows:

 

        PLAYER     HITS     WALKS      OUTS                     

        Ann        20        10        60

        Barb       15        10        64

        Cora       22        9        72

        Deb        29        11        64

        Edna       18        12        55

        Fran       28        10        63

        Gail       21        8        59

        Hilda      20        9        58

        Ina        25        14        70

        Jan        23        15        71

 

 

Use separate loops for each of the following tasks (i.e., USE 4 LOOPS).

 

1.         Read the data into four arrays. 

2.         Calculate the batting average (hits divided by hits plus outs) and the on-base average (hits plus walks divided by hits plus walks plus outs). 

3.         Print the player number, hits, walks, outs, batting average, and on-base average.

4.         Calculate and print the team batting average.

 

OUTPUT

 

                           ONEONTA OTTERS     

 

                                              BATTING    ON-BASE

        PLAYER     HITS     WALKS      OUTS   AVERAGE    AVERAGE

        Ann        20       10        60    0.250     0.333

        Barb       15       10        64    0.190     0.281     

        etc.      etc.      etc.      etc.     etc.       etc.

 

 

        TEAM AVERAGE = 0.257

       

       

 

 

 

                       

Du