Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    How does k get the value of -5? You want k to have values from 0 to the size of the array -1
  2. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    You need to explain what you are trying to do in this statement:

    int [] freq = (int) (Math.random() * 10);

    If freq must be an array, what is the purpose of the call to the random() method?
  3. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    You did not say what you are trying to do. The following will compile:

    int freq = (int) (Math.random() * 10);

    But I don't know what you are trying to do. Please explain.
  4. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    On the left of the = is a definition for an int array
    on the right is a single int value.

    The compiler won't like doing that assignment. It wants the same types on both sides of the =

    What...
  5. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Is it working now?

    If you get errors please copy and paste the full text here.
  6. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Do you understand what values the Random class's nextInt() method returns?
    Add a println to print out the values returned by the method so you can see what it returns.

    Why did you chose that...
  7. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Does it work as you want it to?
  8. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    On line 16 the program tried to use an index that was not in the range of valid indexes for the array. Array indexes start at 0 and go to the array length-1. -3 is not a valid index.

    Please post...
  9. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Go back and reread the assignment. It specifies where the count of the number of loops comes from.
    It is NOT random!!

    If you don't use arrays, that will make the program many times longer than it...
  10. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Do you know about arrays? This program should use an array NOT 10 separate variables.
    What will be done inside of the first loop?
    And then in the second loop?
  11. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    You need to work out the logic of the program before you start writing the code. After you get the logic for the program worked out, you will see where to put the call to the random() method.
    Can...
  12. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Explain what the code needs to do and why you think the Math class's random() method would be useful.
  13. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    The for loop is a better fit when you know how many times you want to loop.
  14. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    That would be one way.
  15. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    That is what the assignment is all about. Go back and read post#1.

    Count the number of numbers in each range.
    Print out *s for each count.
  16. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    To print many characters on one line use the
    System.out.print("<THE CHAR(S) HERE>") method in a loop.
    When you want to go to the next line use the println() method.

    If you have a count of the...
  17. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Where are you having problems? List the steps the program need to do and work on them one at a time.
    When you have a problem with a step, post the code and your questions.
Results 1 to 17 of 17