by Dinesh Thakur Category: Control Structures

In "PigLatin" a word such as KING is replaced by INGKAYand TROUBLE is replaced by OUBLETRAY and so on. The first vowel of the original word becomes the start of the translation, any proceeding letters being shifted towards the end and followed by AYwords that begin with vowels are left on changed.

 

Algorithm for translate the word in piglatin:

step 1: read String input

step 2: set char array chinput[]=input. toCharArray()

step 3: Initialize i=0

step 4: repeat through step-9 while(i<chinput.length)

step 5: if(chinput[i]='a' II chinput[i]='e' II chinput[i]=i' II chinput[i]= '0' || chinput[i]=='u' then execute following steps otherwise jump to step-9

step 6: set String ss=input.substring(i).toUpperCase()+ input. substring(0,i). toUpperCase()+"AY";

step 7: print ss

step 8: goto step-10

step 9: i=i+ 1

step 10: Exit

Here is the Java Example for translatethe word in piglatin:

import java.io.*;

public class PigLatin
{
                      public static void main(String[] args) throws IOException
              {
                         System.out.print("Enter a Word For Translation to PigLatin : ");
                         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                         String input= br.readLine();
                         System.out.println(input);
                         char[] Latin=input.toCharArray();
                             for(int i=0;i<Latin.length;i++)
                                 {
                                     if(Latin[i]=='a' || Latin[i]=='e' || Latin[i]=='i' || Latin[i]=='o' || Latin[i]=='u')
                                         {
                                             String ss=input.substring(i).toUpperCase()+input. substring(0,i).toUpperCase()+"AY";
                                             System.out.println("Translated Word to PigLatin is : " +ss);
                                             break;
                                         }
                                 }
                 }
}

translate the word in piglatin



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content





Popular Article