# Thread: Multidimensional Array Program Trouble

1. Member Join Date
Mar 2013
Posts
21
Rep Power
0

## Multidimensional Array Program Trouble

We were given a task to create a program that would get x, y, and z coordinates fro a user as well as how many data points (n), they want in return. The program is supposed to return 'n' number 3D data points that is stored in a 3D array. The spatial data points should run from the -x to x, -y to y and -z to z. I am confused on how the structure of the program should be and how the spatial data points can be created. Any steps or help is appreciated!
Last edited by incxx; 09-17-2013 at 04:44 AM.  Reply With Quote

2. ## Re: Multidimensional Array Program Trouble

Do you know how to read user input? Do you know what 2D, 3D, ... nD arrays are and how to make one? Those would be the logical starting points.  Reply With Quote

3. Member Join Date
Mar 2013
Posts
21
Rep Power
0

## Re: Multidimensional Array Program Trouble Originally Posted by quad64bit Do you know how to read user input? Do you know what 2D, 3D, ... nD arrays are and how to make one? Those would be the logical starting points.
I know how to read user input and the structure of the array, what is throwing me off is how to create a different range for each of the x, y, and z values, in the array, and then obtaining a random data point.  Reply With Quote

4. ## Re: Multidimensional Array Program Trouble

how to create a different range for each of the x, y, and z values
When you say range, do you mean you want to enforce the value of each dimension, for example: x should only accept values between 0 and 10, y should only accept 1 to 10, and z should only accept 0 to 60? Something like that?

and then obtaining a random data point.
That's simple - have you used class Random before? nextInt(maxValue) is great for this kind of thing.  Reply With Quote

5. Member Join Date
Mar 2013
Posts
21
Rep Power
0

## Re: Multidimensional Array Program Trouble Originally Posted by quad64bit When you say range, do you mean you want to enforce the value of each dimension, for example: x should only accept values between 0 and 10, y should only accept 1 to 10, and z should only accept 0 to 60? Something like that?

for the range, I mean if a user enters x as 5, y as 8 and z as 7, the range of the possible random data points that will be printed will be from: x= -5 to 5, y= -8 to 8 and z= -7 and 7. Im unsure on how to execute this in my program. ex. a point with these numbers could be x=4, y= 5 and z= -2.  Reply With Quote

6. Senior Member Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
14

## Re: Multidimensional Array Program Trouble

I recommend the first thing to do is to write a small program to generate random numbers within a range which could include from -a to +b. Try and work it out on paper. Once you get that done, the rest is relatively easy.

Regards,
Jim  Reply With Quote

7. ## Re: Multidimensional Array Program Trouble

I agree with Jim. If you can generate random numbers between 0 and 7, then you can also generate random numbers between 0 and 14 and then subtract 7.  Reply With Quote

3d array, array, multidimensional arrays 