import java.util.*;
class VowelAsc
{
public static void main(String args[])
{
int count=0;
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
String [] s=new String[n];
int [] b=new int[40];
for(int i=0;i<n;i++)
{
s[i]=sc.next();
}
for(int i=0;i<s.length;i++)
{
char[] a=s[i].toCharArray();
for(int c=0;c<a.length;c++)
{
if(a[c]=='a' || a[c]=='e' || a[c]=='i' || a[c]=='o' || a[c]=='u' ||a[c]=='A' ||a[c]=='E' || a[c]=='I' || a[c]=='O' || a[c]=='U')
{
count++;
//b[c]=count;
}
}
if(count>0)
{
if(i<s.length)
{
String t=s[i];
s[i]=s[i+1];
s[i+1]=t;
}
}
}
}
}
I am trying to count the vowels present in each string and i wanted to swap the strings based on count variable which i am unable to do. After accepting the strings i am converting it into char array with toCharArray() function and comparing each character with lower and upper case vowels.
I am getting an error. Any help in writing the part of the code would be appreciated.
Input:
n=4
xyz
bad
aeiou
hello
Output:
aeiou
hello
bad
xyz