import java.io.*; import java.util.Random; public class ProcGen { public static void main(String[] args) throws IOException{ if(args.length < 1){ System.out.println("USAGE:"); System.out.println(" java ProcGen n filename"); System.out.println(" n: the number of " + "processes to generate."); System.out.println(" filename: (optional) the name of the " + "output file."); System.exit(0); } int n = Integer.parseInt(args[0]); PrintStream out; if(args.length > 1){ out = new PrintStream(new FileOutputStream(args[1])); } else { out = System.out; } out.println(n); Random rand = new Random(); int start = 0; for(int i = 0; i < n ; i++){ int burst = 10 + 10*rand.nextInt(10); int priority = rand.nextInt(10); out.print(i + " "); out.print(priority + " "); out.print(start + " "); out.println(burst + " "); start += rand.nextInt(burst + 10); } out.close(); } }