Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By jim829

Thread: Multidimensional Array Program Trouble

  1. #1
    incxx is offline Member
    Join Date
    Mar 2013
    Posts
    21
    Rep Power
    0

    Default 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.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default 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.

  3. #3
    incxx is offline Member
    Join Date
    Mar 2013
    Posts
    21
    Rep Power
    0

    Default Re: Multidimensional Array Program Trouble

    Quote Originally Posted by quad64bit View Post
    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.

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default 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.

  5. #5
    incxx is offline Member
    Join Date
    Mar 2013
    Posts
    21
    Rep Power
    0

    Default Re: Multidimensional Array Program Trouble

    Quote Originally Posted by quad64bit View Post
    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.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    2,936
    Rep Power
    4

    Default 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
    quad64bit likes this.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  7. #7
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default 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.

Similar Threads

  1. multidimensional array prob T_T
    By raffs03 in forum New To Java
    Replies: 3
    Last Post: 06-15-2013, 12:14 AM
  2. .txt file to multidimensional array
    By Hazza in forum New To Java
    Replies: 1
    Last Post: 11-13-2012, 04:37 PM
  3. Multidimensional Array
    By TyCox94 in forum New To Java
    Replies: 11
    Last Post: 09-25-2011, 11:00 PM
  4. Multidimensional Array help
    By Gaebril in forum New To Java
    Replies: 1
    Last Post: 04-09-2011, 08:36 PM
  5. [SOLVED] Multidimensional array
    By Torgero in forum New To Java
    Replies: 20
    Last Post: 03-22-2009, 11:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •