Hey im stuck on a question that i need to do, i have pretty much the basics of the programme but am not sure how to get it implemented so that it'll work. The question is :
Declare a two dimensional array with 10 rows and 10 columns and initialise:
a) All the elements of its third row to 10
b) All the elements of its 6th column to 20
c) And all the other elements to 5
in that order.
I have the following piece of code that is pretty much the core of the program:
So if anyone can figure out how to implemet it to work correctly id be delighted. Two solid days of java has pretty much turned my brain to mush :(
Declare a two dimensional array with 10 rows and 10 columns and initialise:
a) All the elements of its third row to 10
b) All the elements of its 6th column to 20
c) And all the other elements to 5
in that order.
I have the following piece of code that is pretty much the core of the program:
Code:
import uwejava.*;
import glos.*;
public class exc4
{
public int nums;
for(int y = 0; y < nums.length; ++y)
for(int x = 0; x < nums[i].length; ++x)
if(y == 2)
nums[y][x] = 10;
else if(x == 19)
nums[y][x] = 20;
else
nums[y][x] = 5;
}
Comment