Search:

Type: Posts; User: KevinWorkman

Search: Search took 0.14 seconds.

  1. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    I would still say your multiply variable is pretty unnecessary.

    But if I were you, I wouldn't spend so much time making sure everything is perfect. Does it work? Does it do what you expect? If so,...
  2. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    Yes, that's what I would expect to happen.

    Maybe it would be easier to see what was going on if you only did, say, the first 10 or less iterations. What is num each time? What is thirteen (which...
  3. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    I'm glad you got it working, but for posterity's sake, I should just point out that your "num" variable isn't really necessary.

    Hint- What is sum when compared to thirteen each iteration?
  4. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    What about it don't you understand? Have you stepped through that line with a debugger? Have you at least used print statements to figure out what's going on?
  5. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    What? Why would it? Have you followed any of the advice I gave you so far?
  6. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    Yes. If you don't believe me, try figuring out what's in the first index (which is index zero). Or try printing out the number of elements in the array. Hint- increment a variable each time you add...
  7. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    No. Like I told you, like javapenguin spoonfed you, and like it undoubtedly says on every array tutorial out there- indexes start at zero, not one. So you start at zero and go up to the number of...
  8. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    So, what does your program do now? You need to provide more information if you want any help. I explained how you're going out of the bounds of the array. What about that don't you understand?
  9. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    You never increment the variable in your loop. I'm actually a little surprised that compiles.

    But even when you fix that, you're still accessing the indexes wrongly- remember, the indexes go from...
  10. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    Once again, I'm forced to tell you that spoonfeeding is NOT helping. You have robbed yet another OP of the process of figuring out the problem, which is extremely important for a programmer to learn,...
  11. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    I understand that part, I just don't understand why you were asking about making a loop when you already have almost exactly what you needed in your original post.

    Think about the relationship...
  12. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    I don't understand the question. You already have a loop that goes from 1 to 400 in your original post. It shouldn't be too hard to loop from 0 to 399.
  13. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    First off, you only have to store 400 numbers. So your array should have 400 indexes. And you don't want to store the values to the array in indexes equal to the value, you store them sequentially...
  14. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    The Exception is pretty self-explanatory. Your array has 1200 elements, so 1199 is the last index. You're trying to access index 1560, which is way off. Why are you holding such a small number of...
  15. Replies
    39
    Views
    4,741

    [SOLVED] Re: A little assignment involving arrays.

    That syntax is incorrect. Recommended reading: Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
Results 1 to 15 of 15