// Arup Guha
// 7/16/08
// Slightly edited previous solution on file for BHCSI problem: Frequency.

import java.io.*;
import java.util.*;

class frequency
{
	
	public static void main(String [] args)throws FileNotFoundException
	{
		
		//input our string of characters from a file
		Scanner stdin = new Scanner(System.in);

		System.out.println("What file would you like to process?");
		String fileName = stdin.next();
		Scanner inFile = new Scanner(new File(fileName));
		
		String s = new String("");

		// Read in the whole file into the string. This 
		// string does NOT have whitespace, but that's okay
		// according to the problem specification.
		while (inFile.hasNext())
			s = s + inFile.next();
		inFile.close();

		int letter = 0;
		int max = 0;
		
		//allocate memory for our array
		int[] alphabet = new int[26];
	
	
		for(int i = 0; i < 26; i++)
			alphabet[i] = 0;
	
		//convert our string to all lowercase characters so we dont have to test for both
		s.toLowerCase();
		
		
		for(int i = 0; i < s.length(); i++)
		{
			letter = s.charAt(i) - 'a';
			
			if((letter >=0) && (letter < 26))
			{
				alphabet[letter]++;
				if(alphabet[letter] > max)
					max = alphabet[letter];				
			}
				
		}
		
		//print out results
		for(int i = max; i > 0; i--)
		{
			System.out.print(i + ":\t");
			
			for(int j = 0; j < 26; j++)
			{	
				if(alphabet[j] >= i)
					System.out.print("*");
				else
					System.out.print(" ");
				
			}
			
			System.out.println("");
		}
		
		System.out.println("----------------------------------");
		System.out.println("\tabcdefghijklmnopqrstuvwxyz");
		
		
		
		
	}
	
}
