forked from markandey007/hacktoberfest_2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reversevoweljava
47 lines (42 loc) · 1.23 KB
/
reversevoweljava
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
import java.util.*;
public class vowelrev
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int i=0;
char ch[]=s.toCharArray();
int j=ch.length-1;
while(i<j)
{
if((ch[i]=='a' || ch[i]=='e' || ch[i]=='i' || ch[i]=='o' || ch[i]=='u') && (ch[j]=='a' || ch[j]=='e' || ch[j]=='i' || ch[j]=='o' || ch[j]=='u'))
{
char ch2=ch[i];
ch[i]=ch[j];
ch[j]=ch2;
i++;
j--;
}
else if((ch[i]=='a' || ch[i]=='e' || ch[i]=='i' || ch[i]=='o' || ch[i]=='u') && (ch[j]!='a' || ch[j]!='e' || ch[j]!='i' || ch[j]!='o' || ch[j]!='u'))
{
j--;
}
else if((ch[i]!='a' || ch[i]!='e' || ch[i]!='i' || ch[i]!='o' || ch[i]!='u') && (ch[j]=='a' || ch[j]=='e' || ch[j]=='i' || ch[j]=='o' || ch[j]=='u'))
{
i++;
}
else
{
i++;
j--;
}
}
String s3="";
for(int m=0;m<ch.length;m++)
{
s3=s3+ch[m];
}
System.out.println(s3);
}
}