Search:

Type: Posts; User: Norm

Page 1 of 2 1 2

Search: Search took 0.13 seconds.

  1. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Glad you got it working.
  2. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Can you write a small program for testing how to use arrays? Leave this program for now.

    Put all the code for the test program in the main() method.
    1)Define an array of int with 5 slots...
  3. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Only one book's name can be stored in anArray[0]. If you want more than one name stored in the array, you need to use a variable for the index instead of [0]. When a name is stored in the array at...
  4. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    That statement puts the current value of books in the first slot in the array.

    Do you want to save a different value of books in another slot in the array?

    Where do you want to save the data...
  5. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Can you explain what you mean?

    see posts #51 and #53
  6. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    That is the same as doing the following:
    int x;
    x = 3;
    x = 4;
    x = 5;
    and expecting x to remember it once had the values 3 and 4. That is NOT the way computers work. x can only have one value,...
  7. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    theArray[theIndex++] = theValue; // save theValue in theArray and incr the index
  8. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    When you store data into an array, you need to change the index's value to point to the element in the array where you want the data stored. Normally the index starts at 0 and increases by 1 for...
  9. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    That is the String returned by an array of Strings toString() method.
    If you want to see the contents of the array, you will need to access each element in the array one at a time using array...
  10. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    That is the String returned by an int array's toString() method.
    If you want to print the array's contents you will need to index into the array to access each element in the array.

    Why are you...
  11. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    The posted code has ONE variable that holds one String that is the value of the last name the user entered.
    If you want to save more than one book name, you will need to change the program to save...
  12. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    What is wrong with the program's output?

    What do you want the output to look like?
  13. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Please copy the full contents of the command prompt window that shows the program's input and output and paste it here. Add some comments showing what you want the output to be.
  14. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    The posted code can't be executed for testing. It is missing a main() method.

    Did you have questions about the code in post#38?
  15. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Please copy the full contents of the command prompt window that shows the program's input and output and paste it here. Add some comments showing what you want the output to be.
  16. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Please copy the full text of the error message and paste it here.
  17. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Change the code so the index's value does not go past the end of the array.
  18. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    At line 57 the code used an index that was past the end of the array. Remember array indexes range in value from 0 to the length-1. If an array has two elements, 0 and 1 are the valid indexes.

    ...
  19. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    What variable are you talking about?
    Use code like you used in testing how to create random numbers back in posts #18 and#22
  20. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    What does the program need to have done and Where does the program need that functionality?
    Often you create a method to do some task and add calls in the program where it needs that task to be...
  21. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    You have tested using the random numbers, so you now should now know to create them.
    What do you not understand about creating random numbers?
    Can you explain what problems you are having now?
  22. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    ??? What does that code do? Did you have a question?
  23. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    Did you change the variables as I suggested? When i1 is 9 the loop ends.


    You won't want to print an infinite list of numbers.
  24. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    One problem with that code is that it uses the same variable for controlling the loop and for receiving the random number. They should be different variables.

    Did you run the program several...
  25. Thread: Random variant.

    by Norm
    Replies
    64
    Views
    3,897

    Re: Random variant.

    The message must be about the IDE. You need to ask in the IDE section about the problem.
Results 1 to 25 of 32
Page 1 of 2 1 2