Script to generate a table of random integers of given length on X and Y dimensions, so 4x4 would produce:
https://newage.ql.lt/projects/java/NumberGen.java
CREDITS: Kulverstukas
Quote:11 11 11 11
11 11 11 11
11 11 11 11
11 11 11 11
https://newage.ql.lt/projects/java/NumberGen.java
Code:
package NumberGen;
import java.util.Random;
/**
*
* author Kulverstukas
* ----
* Generates a XxY square of random numbers
* of given length in X and Y.
*
*/
public class NumberGen {
public static void PrntHlp() {
System.out.println(" Usage:\n" +
"\tNumberGen N X Y\n" +
"\tWhere N is a number of numbers\n" +
"\tand X is a number on X axis\n" +
"\tand Y is an number on Y axis.\n" +
"\t\tExample: NumberGen 5 5\n");
}
public static void main(String[] args) {
PrntHlp();
if (args.length <= 1 ) { System.out.println("\nNot enough args given!"); }
else if (args.length >= 2) {
int X = Integer.parseInt(args[0]);
int Y = Integer.parseInt(args[1]);
Random Rand = new Random();
for (int CountY = 1; CountY <= Y; CountY++) {
for (int CountX = 1; CountX <= X; CountX++) {
System.out.print((Rand.nextInt(89)+10)+" ");
if (CountX == X) { System.out.print("\n"); }
}
}
}
}
}
CREDITS: Kulverstukas