Upcoming Batch are :

6 Month Training and 6 Week Training

>
courses :
WebDesignPhp 8.2 Laravel 10.X
Angular Js React Js Node Js
Python 3.11 Django Java
Advance Java Hibernate 4.X Spring 4.X

Enquire now Call us now

Your message has been sent. Thank you!

please contact khalsasoft@gmail.com

Batting data since 1871 is included in the attached Batting.csv (sourced from Github) Player data is included in the attached People.csv (Note, I had to delete data from 1936-1989 due to Zybooks having a limit on file upload sizes).

Using this data, write a program that computes statistics about players and prints with a configurable output.

Prompt the user for:

  • Player description (name/given/id):
    • Valid choices are name, given, or id.
    • name will later print the player description as "nameFirst nameLast" from the People.csv
    • given will later print the player description as nameGiven from the People.csv
    • id will later print the player description as id from the Batting.csv
    • any other choice will cause the program to print the string "invalid" and prompt again
  • Statistic (avg/abhr):
    • Valid choices are avg or abhr.
    • avg will later print the batting average for the player. This is computed as: hits / at bats. The higher the better.
    • abhr will later print the at bats per home run for the player. This is computed as: at bats / home runs. The lower the better.
    • any other choice will cause the program to print the string "invalid" and prompt again
  • Top:
    • The number of players to print data for.
    • defaults to 5 if no value is provided
    • any non-integer will print the string "invalid" and prompt again
    • any number 0 or less will cause the program to print the string "positive required" and prompt again
  • Skip:
    • The number of top players to skip.
    • defaults to 0 if no value is provided
    • any non-integer will cause the program to print the string "invalid" and prompt again
    • any negative integer will cause the program to print the string "non-negative required" and prompt again
  • Minimum:
    • The minimum at bats for a player to be considered. If a player has fewer than this number of at bats, they should not be printed or counted as being skipped.
    • defaults to 3000 if no value is provided
    • any other choice will cause the program to print the string "invalid" and prompt again
    • any number 0 or less will cause the program to print the string "positive required" and prompt again

Three sample runs of baseball stats are:

Player description (name/given/id):
id
Statistic (avg/abhr):
avg
Top:

Skip:

Minimum:

cobbty01 0.36633143856580674
hornsro01 0.35872781065088755
jacksjo01 0.3557518570568159
odoulle01 0.3492647058823529
simmoal01 0.3471000447293872
Player description (name/given/id):
bad choice
invalid
Player description (name/given/id):
id
Statistic (avg/abhr):
bad choice
invalid 
Statistic (avg/abhr):
avg
Top:
dog
invalid
Top:
-8
positive required
Top:
5
Skip:
dog
invalid
Skip:
-15
non-negative required
Skip:
0
Minimum:
dog
invalid
Minimum:
-30
positive required
Minimum:
3000
cobbty01 0.36633143856580674
hornsro01 0.35872781065088755
jacksjo01 0.3557518570568159
odoulle01 0.3492647058823529
simmoal01 0.3471000447293872
Player description (name/given/id):
name
Statistic (avg/abhr):
abhr
Top:
1
Skip:
5
Minimum:
50
Ryan O'Hearn 12.416666666666666

NOTE:

Columns in the Battings.csv file are:

player id,year,stint,team,league id,games played,at bats,runs,hits,2nd base hits,3rd base hits,homeruns,runs batted in,stolen base,caught stealing,walk,strikeout,intentional walk,hit by pitch,sacrificial bunt,sacrificial fly,ground into double play

If you're having issues with verifying your numbers are correct, I recommend downloading the files and trimming them down significantly to work with a smaller data set.