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;
}
}
} |