Source:

// Question 13.11
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class q1311 extends Applet implements ActionListener
{
int n[], frequency[], f;
Button btn;

public void init()
{
n = new int[100];
frequency = new int[100];

btn = new Button("Recalculate");
btn.addActionListener(this);
add(btn);
}

public void paint(Graphics g)
{
int xPos = -80;
int yPos = 30;
int k = 0;

for (int z = 0; z < frequency.length; z++)
frequency[z] = 0;

generate();

for (int j = 1; j <= 4; j++)
{
for (int i = 1; i <= 25; i++)
{
n[(i-1)+k] = i+k;
g.drawString(n[(i-1)+k]+"",xPos + 100 * j, yPos + 14 * i);
g.drawString(frequency[(i-1)+k]+"",xPos + 30 + 100 * j, yPos + 14 * i);

g.fillRect(xPos + 40 + 100 * j, yPos - 9 + 14 * i, (frequency[(i-1)+k] * 10), 8);
}
k += 25;
}
}

public void actionPerformed(ActionEvent e)
{
repaint();
}

private void generate()
{
for (int r = 0; r < frequency.length; r++)
{
f = (int) (Math.random() * 100);
++frequency[f];
}
}
}