Homework 4

Due Thurs. Nov 18, 18:00

Exercise: (10 points)

Write a program called SyllableCounter which estimates the number of syllables in each input word using the following rules: Sample words and their syllable counts (using the rules above):

Example word Expected syllable count
a 1
oi 1
hi 1
try 1
regal 2
real 1
grotto 2
late 1
supercalifragilisticexpialidocious 13
hmmm 1
be 1

Optional:
Read the input words from a file (the file wordList.txt contains all of the sample words above) instead of making the user type them in. This involves three steps:
  1. import java.io.*;
  2. add a throws clause to the main method like this:
    public static void main(String[] args) throws FileNotFoundException
    {
  3. create a Scanner object on the file wordList.txt like this:
    Scanner fileScan = new Scanner(new File("wordList.txt"));

  4. -  fileScan now reads from the file wordList.txt, rather than the keyboard. (Make sure that the input file is in the same directory as the program)
    -  there is no need to prompt the user since they don't have to type anything

Sample output:

a  1
oi  1
hi  1
try  1
regal  2
real  1
grotto  2
late  1
supercalifragilisticexpialidocious  13
hmmm  1
be  1



Submit the following file to Anne (javaiscl (at googlemail.com)):
SyllableCounter.java