Ak Java Freak
Posts : 23 Join date : 2009-02-07
| Subject: replace vowel with underscore using array of character Mon Mar 30, 2009 4:18 am | |
| - Code:
-
import java.io.*; public class NewClass { public static void main(String args[])throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); char word[] = new char[20]; int index1;
System.out.print("Enter a word: "); reader.read(word, 0, word.length); // array of char , starting offset, array length for(index1 = 0; index1 < word.length; index1++) { if(word[index1]=='a' || word[index1]=='e' || word[index1]=='i' || word[index1]=='o' || word[index1]=='u') { word[index1]='_'; } } System.out.println(word); } }
| |
|