On base and batting average in java