The program I am trying to make is a Pig Latin converter. It converts English - Pig Latin.
When the program restarts then there seems to be an error on line 15. Could you please tell me why and the code to fix it? (I have created this code in Eclipse)


import java.util.Scanner;

public class PigLatinConvertor {
public static void main (String args[]){
boolean start = true;
while(start){
Scanner input = new Scanner(System.in);

System.out.print("Enter any word: ");

String word = "a";

String letter = "y";

word = input.next();

int length = word.length();

char vowel = word.charAt(0);

if(vowel=='a'||vowel=='A'||vowel=='e'||vowel=='E'||vowel=='i'||vowel=='I'||vowel=='o'||vowel=='O'||vowel=='u'||vowel=='U'){
System.out.println(word + "way");
System.exit(0);
}
else{
int i = 0;
for (i = 0; i < word.length(); i++){
if (word.charAt(i)=='a' || word.charAt(i)=='e' ||
word.charAt(i)=='i' || word.charAt(i)=='o' ||
word.charAt(i)=='u' || word.charAt(i)=='y'){
break;
}
}
int j = i;
if (word.contains(letter)){
if (j == 0){
String word5 = word.substring(0, j + 1);
String word6 = word.substring(j + 1, length);
System.out.println(word6 + word5 + "ay");
}
else{
String word7 = word.substring(0, j);
String word8 = word.substring(j, length);
System.out.println(word8 + word7 + "ay");
}
}
else{
String word3 = word.substring(0, j);
String word4 = word.substring(j, length);
System.out.println(word4 + word3 + "ay");
}
}
System.out.println("Do you want to continue? [Y/N]");
String s = input.next();
char restart = s.charAt(0);
if(restart != 'Y') start = false;
input.close();
}
}
}