// Arup Guha
// 6/20/06
// 2006 BHCSI Created in class to count the frequency of letters in a file.
import java.util.*;
import java.io.*;
public class Freq {
	
	public static void main(String[] args) throws IOException {
		
		Scanner stdin = new Scanner(System.in);
		
		// Get the file.
		System.out.println("Enter the file you want to count.");
		String filename = stdin.next();
		
		Scanner fin = new Scanner(new File(filename));
		
		// Create the frequency array and initialize it.
		int[] counters = new int[26];
		for (int i=0; i<counters.length; i++)
			counters[i] = 0;
		
		// Loop through each token in the input file.
		while (fin.hasNext()) {
			String temp = fin.next();
			
			// For each character in the current token, update the appropriate
			// counter if necessary.
			for (int j=0; j<temp.length(); j++) {
				char curchar = temp.charAt(j);
				
				// Check if the current character is alphabetic the old
				// fashioned way. Notice how the array is indexed.
				if ('A' <= curchar && curchar <= 'Z')
					counters[(int)(curchar - 'A')]++;
				else if ('a' <= curchar && curchar <= 'z')
					counters[(int)(curchar - 'a')]++;
			}
		}
		
		// Print out the beginning of the chart.
		System.out.println("Letter\tFrequency");
		System.out.println("------\t---------");
		
		// Loop through all the letters.
		for (int i=0; i<26; i++) {
			System.out.print((char)(i+'A')+"\t");
			
			// Print out the appropriate frequency, either as a number, or
			// that many stars for a bar graph.
			
			//System.out.println(counters[i]);
			for (int j=0; j<counters[i]; j++)
				System.out.print("*");
			System.out.println();
		}
	}
}