// declare and initialise x2Coord constant
stopValue = (int)(Math.random() * 20 + 1); // generate a random termination value
counter = 1; // initialise the loop control variable
while (counter <= stopValue) // loop stopValue times
{
g.drawLine(x1Coord, y1Coord, x2Coord, counter * 10);
counter = counter + 1; // increment the loop control variable
}
g.drawString(stopValue + " Nice lines", 20, counter * 10 + 20);