package csci3366.hw3; /** * Class to test SimpleLCG. */ public class TestSimpleLCG { /** * Main method for simple testing. * @param args command-line arguments, seed and number of samples */ public static void main(String[] args) { String usageMsg = "arguments: seed, number of samples"; if (args.length < 2) { System.err.println(usageMsg); System.exit(1); } int seed = 0; int numSamples = 0; try { seed = Integer.parseInt(args[0]); numSamples = Integer.parseInt(args[1]); } catch (NumberFormatException e) { System.err.println(usageMsg); System.exit(1); } SimpleLCG gen = new SimpleLCG(seed); for (int i = 0; i < numSamples; ++i) { long n = gen.next(); double d = (double) n / (double) SimpleLCG.RANDMAX; System.out.printf("%20d %17.15f\n", n, d); } } }