I want the integer results to print out into four columns. How can I do this from the following code?
import java.util.Random;
public class RanX {
public static void main(String[] args) {
int x;
int y;
//pull from command line argument
x = Integer.parseInt(args[0]);
y = Integer.parseInt(args[1]);
//for loop to generate random numbers
for(int r = 0; r < x; r++){
double newr = Math.random()*y;
int z = (int) newr;
System.out.println(z);
}
}
}
import java.util.Random;
import java.util.Scanner;
public class RanX {
public static void main(String[] args) {
int x;
int y;
if(args.length == 2) {
//pull from command line argument
x = Integer.parseInt(args[0]);
y = Integer.parseInt(args[1]);
}
else{
System.out.println("You did not provided two command line arguments");
Scanner scanner = new Scanner(System.in);
System.out.print("Enter value for x: ");
x = scanner.nextInt();
System.out.print("Enter value for x: ");
y = scanner.nextInt();
}
//for loop to generate random numbers
for(int r = 0; r < x; r++){
if(r%4 == 0 && r!=0){
System.out.println();
}
double newr = Math.random()*y;
int z = (int) newr;
System.out.print(z+" ");
}
}
}


I want the integer results to print out into four columns. How can I do this...