import java.util.*;//I am using SCANNER CLASS TO TAKE INPUT
class piglatin
{
public void main()
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the String that is to be converted to PIGLATIN");
String nm = in.next();//Taking INPUT from the user
int check = -1 ;
nm = nm.toUpperCase();//Converting String 'nm' to Upper case
for(int i = 0 ; i<nm.length();i++)
{
char ch = nm.charAt(i);//Extracting every character from the String
switch (ch)//Checking whether that character is a vowel or not
{
case 'A':case 'E':case 'I':case 'O' :case 'U'://Using FALL THROUGH
check = nm.indexOf(ch);//Taking Out the index of the vowel
break;
}
if(check>-1)//The index would be Positive indicating that a vowel has been found
break;
}
String before_vowel = nm.substring(0,check);//Taking the part of String before the vowel
String after_vowel = nm.substring(check);//Taking the part of String after the vowel[including the vowel]
String pigltn = after_vowel+before_vowel+"AY";
System.out.println("The PIGLATIN WORD OF "+nm+" is "+pigltn);
}
}
class piglatin
{
public void main()
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the String that is to be converted to PIGLATIN");
String nm = in.next();//Taking INPUT from the user
int check = -1 ;
nm = nm.toUpperCase();//Converting String 'nm' to Upper case
for(int i = 0 ; i<nm.length();i++)
{
char ch = nm.charAt(i);//Extracting every character from the String
switch (ch)//Checking whether that character is a vowel or not
{
case 'A':case 'E':case 'I':case 'O' :case 'U'://Using FALL THROUGH
check = nm.indexOf(ch);//Taking Out the index of the vowel
break;
}
if(check>-1)//The index would be Positive indicating that a vowel has been found
break;
}
String before_vowel = nm.substring(0,check);//Taking the part of String before the vowel
String after_vowel = nm.substring(check);//Taking the part of String after the vowel[including the vowel]
String pigltn = after_vowel+before_vowel+"AY";
System.out.println("The PIGLATIN WORD OF "+nm+" is "+pigltn);
}
}
No comments:
Post a Comment