# Multidimensional Array Program Trouble

• 09-17-2013, 02:57 AM
incxx
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!
• 09-17-2013, 04:20 AM
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.
• 09-17-2013, 04:43 AM
incxx
Re: Multidimensional Array Program Trouble
Quote:

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.
• 09-17-2013, 04:05 PM
Re: Multidimensional Array Program Trouble
Quote:

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?

Quote:

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.
• 09-17-2013, 10:13 PM
incxx
Re: Multidimensional Array Program Trouble
Quote:

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.
• 09-17-2013, 11:52 PM
jim829
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
• 09-18-2013, 02:21 AM