write a java program to replace the vowels with Asterisk
Answers
Answered by
1
Answer:
Here we are taking input from the user and put it into an character array then by traversing the input we are checking where the vowels are present and replace them with the '*'.
Explanation:
import java.util.Scanner;
class Vowelreplace
{ String sr;
Char vow[];
int i;
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
System.out.println("enter a word or sentence containing vowels");
sr= s.nextLine();
vow= sr.to CharArray();
for(i=0 ; i<vow.length;i++)
{
if( vow[i]= 'a'|| vow[i]= 'e'||vow[i]= 'i'||vow[i]= 'o'||vow[i]= 'u')
{
vow[i]= '*';
}
}
for(i=0 ; i<vow.length;i++)
{
System.out.println(vow[i]);
}
}
}
Similar questions