Results 1 to 8 of 8
  1. #1
    aconti is offline Member
    Join Date
    May 2011
    Posts
    39
    Rep Power
    0

    Default how to store data in array

    Hello,

    how can I let user input 5 numbers and store them automatically in an array ?

    Thanks !

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    While we can't do your homework for you, we can help answer specific questions, and so on that note, can you tell us what specifically have you tried and what specifically has you stuck?
    Last edited by Fubarable; 06-18-2011 at 05:47 PM.

  3. #3
    aconti is offline Member
    Join Date
    May 2011
    Posts
    39
    Rep Power
    0

    Default

    hi,

    in the tutorials I have seen I only saw how to create arrays and manually give them values but nowhere in the examples there was how to make a user input become a value in an array. I am completely stuck since I know how to create arrays and Input messaged but I do not know how to integrate both so that the entered data goes to the array

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    A lot will depend on how you plan to have the user enter data. Will they say be entering 5 numbers separated by a space on one line? Will they be entering each number individually on its own line? Will they be using a console program or a GUI? or JOptionPane?

    If a console program with each number on its own line then what steps do you think you should do? I'll bet that you can work most of this out given what you already know. :)

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Hint: a for loop works quite well with arrays since you can loop from 0 to the array's length and then fill in the array element inside of the loop.

  6. #6
    aconti is offline Member
    Join Date
    May 2011
    Posts
    39
    Rep Power
    0

    Default

    unfortunately is much easier said than done, I would appreciate if you can give me a link to get a better idea from someone who did something similar

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by aconti View Post
    unfortunately is much easier said than done, I would appreciate if you can give me a link to get a better idea from someone who did something similar
    No, it is almost as easily done as said. At least try, then, if you can't, post your attempt and we will help you correct it.

  8. #8
    aconti is offline Member
    Join Date
    May 2011
    Posts
    39
    Rep Power
    0

    Default

    sure I will try to be near as possible before I post so that I will not become red

Similar Threads

  1. How can i store a data from Excel sheet to an array.
    By deshmukh.niraj04 in forum New To Java
    Replies: 0
    Last Post: 05-03-2011, 06:33 AM
  2. HOw to Store Data in An Array
    By deshmukh.niraj04 in forum New To Java
    Replies: 4
    Last Post: 04-06-2011, 04:00 AM
  3. store data into an array from a file
    By chopo1980 in forum New To Java
    Replies: 10
    Last Post: 11-13-2009, 09:48 AM
  4. Comparing two data types in order to store in array
    By gwithey in forum New To Java
    Replies: 3
    Last Post: 05-01-2009, 10:27 AM
  5. Store textfile data in an array
    By mokonji in forum New To Java
    Replies: 4
    Last Post: 02-22-2009, 05:28 PM

Posting Permissions

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