Java Forums
Our Goal is to achieve and build a community. Even if there is nobody on the forum, please register. If we have a small community, people will see we have at least people and they will register. Any people please register!

Cheers,
Slick Java (Owner + Admin)
Java Forums

Share your Java programming ideas here.
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Our Goal is to achieve and build a community. Even if there is nobody on the forum, please register. If we have a small community, people will see we have at least people and they will register. Any people please register! Cheers, Slick Java (Owner + Admin)
We are also looking for moderators and admins.

Share | 
 

 Homework help - pairs of vowels to asterisks

View previous topic View next topic Go down 
AuthorMessage
Slick Java
Admin
Admin
avatar

Posts : 9
Points : 10003155
Join date : 2013-03-15
Age : 16

PostSubject: Homework help - pairs of vowels to asterisks   Tue Mar 19, 2013 2:28 pm

Hello, I have a homework assignment on changing pair of vowels to asterisks.
I have so far achieved changing a single vowel into a asterisk.
I need help on changing pairs of vowels into asterisks.
eg. bookkeeping => b**k**ping not b**kk**p*ng

Output (single vowel):

Type in a word to protect
bookkeeping
b**kk**p*ing

Code:

import java.util.*;
public class HomeworkV03 {
   
    private String chars;
    private Scanner scan = new Scanner(System.in);
    private char[] vowels = {'a','e','i','o','u'};
   
   
   
    public static void main(String args[])
    {
        HomeworkV03 h = new HomeworkV03();
        h.askClient();
        h.printVowels();
    }
   
    public void askClient()
    {
        System.out.println("Type in a word to protect");
        chars = scan.next();
    }
   
    public void printVowels()
    {
        int a = 0;
        char c;
 
       
        for (a = 0; a < chars.length(); a++)
        {
               
           
                c = chars.charAt(a);
                boolean isVowel = isVowel(c);
               
 
               
                if(isVowel )
                {
                   
                    System.out.print("*");
                   
                }
                else
                {
                    System.out.print(c);
                }
           
          }
       
        }
 
    private boolean isVowel(char c)
    {
        int i = 0;
        boolean vowel = false;
       
       
        for (i = 0; i < 5; i++)
        { 
                if(c == vowels[i])
                {
                    vowel = true;
                } 
   
        }
           
        return vowel;
    }
}

Thanks,

Slick Java
Back to top Go down
View user profile http://java.forumstech.com
 
Homework help - pairs of vowels to asterisks
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Just won 3 pairs of Yoga Jeans thanks to ya'll!

Permissions in this forum:You cannot reply to topics in this forum
Java Forums :: New to Java :: Problems + Questions-
Jump to: