noob: two-dimension array
Create a program that generates a 10x10 table. Your program should fill the table with random integers between 0 and 9. Display the contents of your table on the screen as a 10x10 grid. AFTER the numbers have been generated and displayed on the screen, calculate and display the total of the 100 numbers generated.
-I must use multi-dimensional arrays to create this program
Here is my code as of now and it does not run, are my brackets and loops properly placed? Any help is much appreciated.
Code:
public static void main (String[] args)
{
c = new Console ();
//create a 10*10 table
int table[] [];
table = new int [10] [10];
//declare a value that will make a random number between 0 and 9
int randomInt = 0;
randomInt = ((int) (Math.random () * 9)) + 1;
//create a loop to put the random values of 0 to 9 in
int i, j;
//two loops, i for the rows
for (i = 0 ; i < 10 ; i++)
{
table [i] [0] = randomInt;
}
//second loop, j for the columns
for (j = 0 ; j < 10 ; j++)
{
table [0] [j] = randomInt;
}
//every element is assigned the random integer
//print the table on the output screen
c.println (table [i] [j] + " ");
} // main method