Piglatin : Piglatin is a way of forming a word by finding the vowel and trace the alphabhet to the end and adding the "ay" at the End. For example: if the input word is "DEMO" then piglatin word will be "EMODAY". Program below illustrate how to Convert it.
public class PigLatin {
public static void main(String[] args)
{
System.out.println("Enter word: ");
Scanner scanner = new Scanner(System.in);
String FirstVowel = scan.nextLine();
char v = Character.toLowerCase(FirstVowel.charAt(0));
if (v == 'a' || v == 'e' || v == 'i' || v == 'o' || v == 'u')
{
String PigLatin = FirstVowel + "ay";
System.out.println(PigLatin);
}
else
{
String first =FirstVowel.substring(0,1);
String term =FirstVowel.substring(1,FirstVowel.length());
System.out.println(term + first + "ay");
}
}
}
0 Comment(s)