Free help with homework

Why join Brainly?

  • ask questions about your assignment
  • get answers with explanations
  • find similar questions

Write a program in java to accept a string in upper case and replace all the vowels present in the string with asterisk(*).



Import java.util.*;
class Replace
void main()
Scanner sn = new Scanner(System.in);
S.o.p("Enter a String: ");
String s = sn.nextLine();
int n=s.length();
for(int i=0; i<=n-1; i++)
char ch=s.charAt(i);
if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch== 'U')
String s1 = s.replace(ch,*);
S.o.p("New String: "+ s1);
3 3 3
pls mark as the best!!!
but will it print the'*'star sign
as the character has been replaced with '*'
The Brain
  • The Brain
  • Helper
Not sure about the answer?
Learn more with Brainly!
Having trouble with your homework?
Get free help!
  • 80% of questions are answered in under 10 minutes
  • Answers come with explanations, so that you can learn
  • Answer quality is ensured by our experts