Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: I need to accept a sentence and see if any words have consecutive vowels and how many such words r there

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post I need to accept a sentence and see if any words have consecutive vowels and how many such words r there

    but im getting an error, here
    import java.io.*;
    class Check
    {
    public static void main(String adish[])throws IOException
    {
    BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
    String s; boolean f=false;
    System.out.println("Whats on your mind? ");
    s=br.readLine();
    s=s+" ";
    int l,ll;
    l=s.length();
    int i,k,v1,c; char ch;c=0;
    String w=" ";
    for(i=0;i<l;i++)
    {
    ch=s.charAt(i);
    if(ch!=' ' && ch!='.' && ch!=',')
    {
    w=w+ch;
    }
    if(ch==' ' || ch=='.' || ch==',')
    {
    ll=w.length();
    w=w.toUpperCase();
    for(k=0;k<ll;k++)
    {
    if(w.charAt(k)=='A' || w.charAt(k)=='E' || w.charAt(k)=='I' || w.charAt(k)=='O' || w.charAt(k)=='U' && w.charAt(k+1)=='A' || w.charAt(k+1)=='E' || w.charAt(k+1)=='I' || w.charAt(k+1)=='O' || w.charAt(k+1)=='U')
    {
    System.out.print(w+" ");
    c=c+1;
    f=true;
    w=" ";
    }
    }
    }
    }
    System.out.println(c);
    }
    }


    what i get is in the attachment
    Attached Images Attached Images


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: I need to accept a sentence and see if any words have consecutive vowels and how many such words r there

    Hi,

    Please can you post your code in proper manner so that it can be easily readable and understood. Please check the below for reference:
    Announcements - What's Wrong With My Code?

    I feel like the logic you are trying to implement is not proper. Few modifications are required. You want to segregate all the words from a sentence. Check each word having consecutive vowels. While making a read over the word, keep in mind that if charAt(K) is the last letter, then charAt(K+1) should not be compared.

    Its always a good programming practise to use sensible and meaningful variable name.
    Thanks and regards,
    Sambit Swain

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,329
    My Mood
    Mellow
    Thanks
    253
    Thanked 781 Times in 766 Posts

    Default Re: I need to accept a sentence and see if any words have consecutive vowels and how many such words r there

    Welcome to the forum. Post your code correctly according to the instructions given at the link Sambit provided.

Similar Threads

  1. Replies: 6
    Last Post: October 26th, 2013, 02:59 PM
  2. Replies: 12
    Last Post: March 17th, 2013, 02:38 AM
  3. how do you compare words?
    By beginner123 in forum Java Theory & Questions
    Replies: 12
    Last Post: November 18th, 2012, 08:44 AM
  4. Arranging words in a sentence in alphabatical order.
    By J2000 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 24th, 2011, 10:04 AM
  5. Help: Num to words
    By shamed in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 7th, 2010, 06:55 PM