212k views
3 votes
Write a program which takes a string input, converts it to lower case, then prints the same string with all vowels (a, e, i, o, u) removed.

Hint: one good way to do this is to make a new String variable and add all the letters you want to print (i.e. everything except vowels) to it.

Sample Run:

Enter String:
Animation Rerun
nmtn rrn

User Cybot
by
5.4k points

1 Answer

5 votes

Answer:

Scanner scan = new Scanner(System.in);

System.out.println("Enter String:");

String v = "aeiou";

String t = scan.nextLine();

t =t.toLowerCase();

String nt ="";

for(int i = 0; i < t.length(); i++){

char c = t.charAt(i);

if (v.indexOf(c) == -1){

nt += c;

}

}

System.out.println(nt);

}

}

Step-by-step explanation:

Good Luck

User John Rogers
by
4.6k points