FileDocCategorySizeDatePackage
addRandom.javaAPI DocExample595Wed Aug 02 13:09:54 BST 2000None

addRandom.java

import java.awt.*;			// make the graphics libraries available
import java.applet.*;		// make the applet libraries available
import java.util.*;			// make the random number library available

public class addRandom extends Applet	// make a new applet
{
	private int stopValue;		// used to hold the random number
	private int counter;			// loop control variable
	
	public void paint(Graphics g)
	{
		stopValue = (int) (Math.random() * 20 + 1);
		while (counter <= stopValue)
		{
			g.drawString("counter is " + counter, 20, counter * 10 + 20);
			counter = counter + 1;
		}
	}
}