/* From: "COMPUTATIONAL PHYSICS, 2nd Ed" by RH Landau, MJ Paez, and CC Bordeianu Copyright Wiley-VCH, 2007. Electronic Materials copyright: R Landau, Oregon State Univ, 2007; MJ Paez, Univ Antioquia, 2007; and CC Bordeianu, Univ Bucharest, 2007. Support by National Science Foundation */ // COLUMN/java: Column growth simulation import java.io.*; // Location of PrintWriter import java.util.*; // Location of Random import java.lang.*; // Location of Math public class COLUMN { public static void main(String[] argv) throws IOException, FileNotFoundException { PrintWriter q = new PrintWriter( // Data file new FileOutputStream("COLUMN.DAT"),true); // Initialize 48 bit pseudo-random number generator: long seed = 971761; //Different seed, different sequence Random randnum = new Random(seed); // To access next random double: randnum.nextDouble() int max = 100000, npoints = 200; // Iterations, open spaces int i = 0, dist = 0, r = 0, x = 0, y = 0, oldx = 0, oldy = 0; double pp = 0.0, prob = 0.0; int hit[] = new int[200]; for (i = 0; i0 && r<(npoints-1)) { if ((hit[r] >= hit[r-1]) && (hit[r] >= hit[r+1])) hit[r]++; else if ( hit[r-1] > hit[r+1] ) hit[r] = hit[r-1]; else hit[r] = hit[r+1]; oldx = r; oldy = hit[r]; q.println(r+" "+hit[r]); } } } System.out.println(" "); System.out.println("COLUMN Program Complete."); System.out.println("Data stored in COLUMN.DAT"); System.out.println(" "); } } // End of class