Improved centeredAverage.java