Java program for doing statistics