Java Programming
Would you like to react to this message? Create an account in a few clicks or log in to continue.


here you can ask help for your java related problems
 
HomeLatest imagesSearchRegisterLog in

 

 replace vowel with underscore using array of character

Go down 
AuthorMessage
Ak
Java Freak
Java Freak
Ak


Posts : 23
Join date : 2009-02-07

replace vowel with underscore using array of character Empty
PostSubject: replace vowel with underscore using array of character   replace vowel with underscore using array of character EmptyMon 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);
    }
}
Back to top Go down
https://javafreak.board-directory.net
 
replace vowel with underscore using array of character
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Java Programming-
Jump to: