PigLatin Word in JAVA
PigLatin Word in JAVA
PigLatin Word : A
Pig Latin word is obtained by framing a
new word starting with the first vowel present in the word. The remaining
letters before the first vowel will be added in the last followed by 'ay'.
For Example :-
Input : "trouble"
Output : "oubletray"
Input : "bluejcode"
Output : "uejcodeblay"
Program to print PigLatin Word :-
Program :-
import java.io.*;
import java.util.*;
class Piglatin
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int l,i;
String str,str1,str2,str3;
char ch;
System.out.println("Enter word");
str= in.nextLine();
l= str.length();
for(i=0;i<l;i++)
{
ch=str.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
break;
}
}
str1= str.substring(i);
str2= str.substring(0,i);
str3= str1+str2+"ay";
System.out.println("Original Word : "+str);
System.out.println("Piglatin Word : "+str3);
}//end of main method
}// end of class
import java.util.*;
class Piglatin
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int l,i;
String str,str1,str2,str3;
char ch;
System.out.println("Enter word");
str= in.nextLine();
l= str.length();
for(i=0;i<l;i++)
{
ch=str.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
break;
}
}
str1= str.substring(i);
str2= str.substring(0,i);
str3= str1+str2+"ay";
System.out.println("Original Word : "+str);
System.out.println("Piglatin Word : "+str3);
}//end of main method
}// end of class
For Proper Understanding Watch the Video :-
All the best :)
Keep Learning :)
Comments
Post a Comment