SyllableCounter.java.html

  1  import java.util.Scanner;
  2  
  3  /**
  4     This program counts the syllables of all words in a sentence.
  5  */
  6  public class SyllableCounter
  7  {  
  8     public static void main(String[] args)
  9     {  
 10        Scanner in = new Scanner(System.in);
 11  
 12        System.out.println("Enter a sentence ending in a period.");
 13  
 14        String input; 
 15        do
 16        {
 17           input = in.next();
 18           Word w = new Word(input);
 19           int syllables = w.countSyllables();
 20           System.out.println("Syllables in " + input + ": " 
 21              + syllables);
 22        } 
 23        while (!input.endsWith("."));
 24     }
 25  }