Right now Iam writing a program that will convert english into piglatin. Ans I have pretty much finished the program, but Iam stuck and need help.
When I run the program, nothing happens after I type in the users input. What am I doing wrong.
Heres my code,
import java.util.Scanner;
public class Example {
public static void main(String[] args) {
String englishWord, pigLatin;
Scanner kbd = new Scanner(System.in);
System.out.println("Enter word that you want to translate: ");
String english = kbd.nextLine();
while(english.indexOf(' ') != -1)
{
englishWord = english.substring(0,english.indexOf(' '));
english = english.substring(english.indexOf(' '));
if(englishWord.charAt(0)=='a' || englishWord.charAt(0)=='e' || englishWord.charAt(0)=='i' || englishWord.charAt(0)=='o' || englishWord.charAt(0)=='u')
{
pigLatin = englishWord + "way";
System.out.println(pigLatin);
}
else
{
char firstChar = englishWord.charAt(0);
pigLatin = englishWord.substring(1,englishWord.indexOf(' '))+ firstChar +"ay";
System.out.println(pigLatin);
}
pigLatin = englishWord + " ";
}
}
}
Any help would be thankful.
Thanks