Program to accept a word. Rearrange the vowels by bringing all at beginning followed by the other letters.
Example: “Original”. The program is expected to generate new word that is “Oiiargnl”.
Java
import java.util.*;
public class ArrangeVowel
{
public static void main(String args[])
{
String str="",nstr="",vows="",cons="";
char ch=' ';
int l=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter a word: ");
str=sc.next();
str=str.trim();
l=str.length();
for(int i=0;i<l;i++)
{
ch=str.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
vows=vows+ch;
}
else
{
cons=cons+ch;
}
}
nstr=vows+cons;
System.out.println("New word: "+nstr);
}
}Java