//Percolation.java import java.awt.*; import javax.swing.*; public class Percolation extends JApplet { int rows, cols, percent, scale, rule; String sideflow; public void init() { String input; input = JOptionPane.showInputDialog("Enter # rows"); rows = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter # columns"); cols = Integer.parseInt(input); input = JOptionPane.showInputDialog("Random percentage rock"); percent = Integer.parseInt(input); input = JOptionPane.showInputDialog("Pixel scale factor"); scale = Integer.parseInt(input); input = JOptionPane.showInputDialog("Seepage rule:"+ "\n1. above or either diagonal"+ "\n2. above or both diagonals"); rule = Integer.parseInt(input); sideflow = JOptionPane.showInputDialog("Side flow (yes or no)"); } public void paint (Graphics g) { int [][]W = new int[rows][cols]; for (int i=0; i0; j--) //reverse and "push" water to left nbor if (W[i][j]==2 && W[i][j-1]==0) W[i][j-1] = 2; } //draw water for this row for (int j=0; j