Search Tutorials


Tuesday, 23 April 2013

Java code to find the pigLatin equivalent of a word

Java program to find the pigLatin equivalent of a word.

class PigLatin
static String n;
static int l;
 public static void main(String args[]) throws IOException
 BufferedReader br = new BufferedReader(new InputStreamReader(;
 System.out.print("Enter a word : ");
 n = br.readLine();
 l = n.length();
 public static boolean isVowel(char c)
 String vowels[] = {"a","e","i","o","u"};
 for(int i=0;i<5;i++)
   return true;
 return false;
 public static String toPigLatin()
 int f=-1;
 char c;
 for(int i=0;i<l;i++)
  // Find the location of the 1st vowel, if any
  c = n.charAt(i);
   f = i;
 if(f==0 || f==-1)
  return n;
  // Store part after the vowel
  String b = n.substring(f).toUpperCase();
  // Store part before the vowel
  String d = n.substring(0,f).toUpperCase();
  return b+d+"AY";


1. Start

2. Accept a sentence from the user.

3. Break the word at the first occurring vowel.

5. Set flag f = 1

6. Add the deleted letters to the end of the word.

7. Add “AY” at the end.

8. if(f ==1) then print the changed String.
Print the original String.

9. End


Java code to find the pigLatin equivalent of a word

Enter a word : Mayank


Related Programs:-

Check whether a string is a Palindrome or not

Check the number of Uppercase letters, Lowercase letters, numerals, vowels, spaces & special characters in a string

Read the date, day and year

Read a Date and give the day number

Multiply two Matrices

No comments:

Post a Comment

back to top