//RandomLines.java import java.awt.Graphics; import javax.swing.*; public class RandomLines extends JApplet { int lines; public void init() { String input; input = JOptionPane.showInputDialog("Enter # of random lines"); lines = Integer.parseInt(input); } public void paint( Graphics g ) { int x1, y1, x2, y2; super.paint( g ); //assumes screen area is 800x800 for (int i=1; i<=lines; i++) { x1 = (int)(Math.random() * 800); y1 = (int)(Math.random() * 800); x2 = (int)(Math.random() * 800); y2 = (int)(Math.random() * 800); g.drawLine(x1,y1,x2,y2); } } }