I'm working on a project for my Programming Applications course with WGU. I've decided to adapt a python-based pig latin converter from the previous course. I've almost got it done, but when I run the program, I get an extra word. For example, if I enter Latin, it prints atinLay, then on the next line, prints inLatay.
I'm not sure which part of the code is causing this. I know it should be a simple fix but I just can't find it. Here is my code:
import java.util.Scanner;
public class PigConverter
{
public static void main(String[] args)
{
Scanner anscay = new Scanner(System.in);
System.out.print("Enter a word:");
String word = anscay.nextLine();
System.out.println("This word, in pig latin, would be:");
String pigConvert;
for (int 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')
{
String second = word.substring(0,i);
String first = word.substring(i,word.length());
System.out.println(first+second+"ay");
}
}
}
}