Given a string the task is to change all the vowels present in the string to the succeeding letter.
Example: Consider the string “Lorem Ipsum is simply dummy text”. The program should output “Lprfm Jpsvm js sjmply dvmmy tfxt”. We observe that all the vowels in the original string are changed to next letter.
Java
import java.util.*;
public class VowelReplaceNext
{
public static void main(String args[])
{
int l=0;
char ch=' ';
String str="",nstr="";
Scanner sc=new Scanner(System.in);
System.out.print("Enter the string: ");
str=sc.nextLine();
str=str.trim();
str=str+" ";
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')
{
nstr=nstr+(char)((int)ch+1);
}
else
{
nstr=nstr+ch;
}
}
System.out.println("New string: "+nstr);
}
}Java