Java: Combining counts in an array to get a percentage
<p>I am writing a Frequency Counter that reads a given file returns the frequency (in percentage) of each letter in the file.  My code so far reads the file and lists the count of each letter occurring in the file.  I cannot figure out how combine all of the counts in order to generate the percentages instead.  Below is my code and please forgive if I didn't use the code blocks correctly.  Still learning all of this stuff.</p>

<pre><code>import java.io.File;
import java.util.*;

public class FrequencyCounter
{

    public static void main(String[] args )
    {
        char[] capital = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'N',
                'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

        char[] small =   { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
                'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

        Scanner scan;
        try 
        {
            scan = new Scanner(new File("c://Users//Mikel//Desktop//School Work//CIS407//Week1//mary.txt"));
        } 

        catch (Exception e) 
        {
            System.out.println("File not found");
            return;
        }

        int[] count = new int[26];



        while(scan.hasNextLine()) 
        {
            String line = scan.nextLine();
            System.out.println("Line read: " + line);
            char[] digit = line.toCharArray();


            for(int i = 0; i &lt; digit.length; i++) 
            {
                for(int j = 0; j &lt; 26; j++) 
                {
                    if(digit[i] == capital[j] || digit[i] == small[j]) 
                    {
                        count[j]++;
                        break;
                    }
                }
            }
        }


        for (int i = 0; i &lt; 26; i++)
        {
            System.out.print("  " + capital[i]);
            System.out.println("          " + (count[i]));

        }

    }
}
</code></pre>
