for(int index = 0;index<length;index++) {
if ((word.indexOf(a)!=-1)) {

Examine your code very carefully. If user enters the word "hat" how many times will that if statement be true?