Results 1 to 2 of 2
  1. #1
    babouro is offline Member
    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Default Read from a text file and find the word with the most consecutive vowels. Help me

    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.util.Scanner;
    public class ConsecutiveVowels {

    public static void main(String[] args) {

    Scanner fileIn = null;
    try
    {
    // Attempt to open the file
    fileIn = new Scanner (new FileInputStream("words.txt"));
    }
    catch (FileNotFoundException e)
    {
    //This block is executed if the file is not found
    //and then the program exits
    System.out.println("File not found");
    System.exit(0);
    }
    String theWord;
    int vowelCount = 0;

    fileIn.hasNextLine();
    theWord = fileIn.next();

    System.out.println("The word that has the most consecutive vowels is: ");
    for (int i = 0; i < theWord.length(); i ++ )
    {
    char c = theWord.charAt(i);
    if ( (c == 'A') || (c == 'a')
    || (c == 'E') || (c == 'e')
    || (c == 'I') || (c == 'i')
    || (c == 'O') || (c == 'o')
    || (c == 'U') || (c == 'u'))
    {
    vowelCount = vowelCount + 1;
    }
    }

    }

    }

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Read from a text file and find the word with the most consecutive vowels. Help me

    I don't see a question in your post...I recommend asking one if you wish to receive help. If there are errors, post them in their entirety, and wrap all code in the code tags

Similar Threads

  1. Read the first word of every line in a txt file
    By cherrychives in forum New To Java
    Replies: 1
    Last Post: 10-01-2012, 02:51 PM
  2. Replies: 0
    Last Post: 07-24-2012, 08:07 AM
  3. how to read a word(microsof) file from jva
    By salmainfo in forum New To Java
    Replies: 2
    Last Post: 01-20-2012, 07:17 PM
  4. Replies: 3
    Last Post: 08-30-2011, 04:44 PM
  5. Replacing Vowels in a word.
    By mklprasad in forum Advanced Java
    Replies: 1
    Last Post: 10-05-2009, 12:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •