Completed the method for printing histogram