To get the batting average, you need two things: the number of hits and the number of at bats. Then you divide the hits by the at bats.
Say the person had 100 at bats and 26 hits. You divide:
26/100 = 0.260 batting average.
However, it doesn't count as an "at bat" each time a player comes to the plate. For example, if the batter walks, that doesn't count. Other examples where it's not an at bat: hit by a pitch, sacrifice fly, and a few other obscure things listed in the second reference below.
Reference: http://en.wikipedia.org/wiki/Batting_average#Baseball , http://en.wikipedia.org/wiki/At_bat
Let me know if you have any questions. Don't forget to press "Accept" if this was helpful. Thanks!
No problem! Glad to help.
Sounds like a fun project!