-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathPiglatin.java
More file actions
28 lines (28 loc) · 766 Bytes
/
Piglatin.java
File metadata and controls
28 lines (28 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
public class PiglatinWord
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
System.out.println("Enter the word to be converted.");
String word=ob.next();
word=word.toUpperCase();
String piglatin="";
int flag=0;
for(int i=0;i<word.length();i++)
{
char x=word.charAt(i);
if(x=='A' || x=='E' || x=='I' || x=='O' ||x=='U')
{
piglatin=word.substring(i)+word.substring(0,i)+"AY";
flag=1;
break;
}
}
if(flag==0)
{
piglatin=word+"AY";
}
System.out.println(word+" in Piglatin format is "+piglatin);
}
}