×
/***
This code will help you speak and understand Pig latin.
- If the input starts with consonant or group of consonants, move them to the end and add “ay”
- dog —> “ogday”
- brush —> “ushbray”
- For vowels, add “yay”
- ouch —> “ouchyay”
***/
import java.io.*;
class Main
{
public static void main (String[] args)
{
String word = "ouch";
System.out.println("");
if(word.charAt(0)== 'a'||word.charAt(0)=='e'||word.charAt(0)=='i'
||word.charAt(0)=='o'||word.charAt(0)=='u' )
{
System.out.println(word + "yay");
}
else
{
int vowelIndex = 0;
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')
{
vowelIndex = i;
break;
}
}
System.out.println(word.substring(vowelIndex)+ word.substring(0,vowelIndex) + "ay");
}
}
}