//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 2.16 on page 45

import java.util.Random;

public class Pr0216
{ public static void main(String[] args)
  { String string="Welcome to the new millenium";
    System.out.println(string);
    int[] t = tally(string);
    for (int i=0; i<26; i++)
      System.out.println("Frequency of " + (char)('A'+i)
                       + " = " + t[i]);
  }
  
  private static int[] tally(String s)
  { int[] frequency = new int[26];
    for (int i=0; i<s.length(); i++)
    { char ch = Character.toUpperCase(s.charAt(i));
      if (Character.isLetter(ch))
        ++frequency[(int)ch - (int)'A'];  // count ch
    }
    return frequency;
  } 
}
