Frequency distribution of an array
<p>Hi I am trying to get the frequency of an array for text font sizes and colors, when I have string of words and I count the frequency I want to change the size of the word and color according to their overall value in size, I have tried to divide the <code>frequency/average *10</code>  but gives me null, but on my calculator it gives me ie, 80/100 *10 = 8, this would the take an index of 8 and have 180 font size</p>

<p>can anyone help me with this?</p>

<pre><code>private static int[] fontWeight = { 40, 60, 80, 100, 120, 140, 160,180 };
private static Color[] Colors = { Color.blue, Color.cyan, Color.yellow, Color.green, Color.red,
        Color.orange, Color.pink,Color.pink  };
</code></pre>

<p>//main</p>

<pre><code>  for (String str: wordList) {


            int wordFreq = randWord.getFrequency();//assume 80 comes here
            int fontSize = getFontSize(wordFreq);
            Font font = new Font(Font.SANS_SERIF, Font.ITALIC, fontWeight [fontSize ]);
            graphics.setFont(font);
            graphics.setColor(Colors[fontSize]);
            FontMetrics fm = graphics.getFontMetrics();

            graphics.drawString(randWord.getWord() + "", x, y);
            }
</code></pre>

<p>//method</p>

<pre><code>  private static int getFontSize(int freq) {

    int newFont = (int) (freq/100)*10;

    if (newFont &gt;= 5) newFont = 6;
    // if(newFont&lt;2)
    // newFont = 1;
    System.out.println("freq " + freq + " font index" + newFont + "  font size "
            + fontWeight[newFont]);

    return newFont;
}
</code></pre>

<p>Thanks for your help</p>
