import java.util.Scanner;
public class table {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of rows in the table: ");
int rows = input.nextInt();
System.out.println("Enter the number of columns in the table: ");
int columns = input.nextInt();
//System.out.println("Enter the data for the table: ");
//int data = input.nextInt();
// creates a new 2d array
int [][] table = new int[rows][columns];
// fills the array
for (int i=0; i<table.length; i++){
for (int j=0; j<table[i].length; j++)
table[i][j] = (int)(Math.random() * 1000);
}
printarray(table [rows][columns]);
}
public static void printarray(int x[][]){
for (int i =0; i<x.length;i++ ){
for (int j =0; j<x[i].length;j++)
System.out.print(x[i][j]+" ");
}
System.out.println();
}
}
This post has been edited by zerocool18: 19 November 2012 - 12:28 AM

New Topic/Question
Reply



MultiQuote



|