-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRearrange.java
More file actions
58 lines (54 loc) · 1.56 KB
/
Copy pathRearrange.java
File metadata and controls
58 lines (54 loc) · 1.56 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.io.*;
class Rearrange
{
String txt,cxt;
int len;
public Rearrange()
{
txt=" ";
cxt="";
len=0;
}
void readWord()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a word in upper case");
txt=br.readLine();
}
void convert()
{
char ch;
int i, flag=0;
len=txt.length();
ch=txt.charAt(0);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
cxt=txt+"Y";
else
{
for(i=0;i<len;i++)
{
ch=txt.charAt(i);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
cxt=txt.substring(i)+txt.substring(0,i)+"C";
flag=1;
break;
}
}
if(flag==0)
cxt=txt+"N";
}
}
void display()
{
System.out.println("Original Word "+txt);
System.out.println("Changed Word "+cxt);
}
public static void main(String args[])throws IOException
{
Rearrange ob=new Rearrange();
ob.readWord();
ob.convert();
ob.display();
}
}