Given a sentence the task is to replace every vowel in that sentence with Asterisks (*).
Example: Consider an sentence “Lorem Ipsum is simply dummy text of the printing and typesetting industry”. The program outputs “L*r*m *ps*m *s s*mply d*mmy t*xt *f th* pr*nt*ng *nd typ*s*tt*ng *nd*stry”.
Java
import java.util.*;
public class StarReplaceVowel
{
public static void main(String Args[])
{
String str="",nstr="";
int l=0;
char ch=' ';
Scanner sc=new Scanner(System.in);
System.out.print("Enter a string: ");
str=sc.nextLine();
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')
{
nstr=nstr+'*';
}
else
{
nstr=nstr+ch;
}
}
System.out.print("New string: "+nstr);
}
}Java