forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpiglatinWord,java
33 lines (28 loc) · 819 Bytes
/
piglatinWord,java
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
29
30
31
32
33
import java.util.Scanner;
public class KboatPigLatin
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter word: ");
String word = in.next();
int len = word.length();
word=word.toUpperCase();
String piglatin="";
int flag=0;
for(int i = 0; i < len; 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);
}
}