Search:

Type: Posts; User: jashburn

Search: Search took 0.12 seconds.

  1. Replies
    17
    Views
    1,632

    [SOLVED] Re: Counting input array

    For this last bit it's just because the for loop uses j

    for(int j = 1; j <= 100; j++) {
    but the if tests use number as the index

    if (allNum[number] == 0) {
    ...
    }
    if (allNum[number] ==...
  2. Replies
    17
    Views
    1,632

    [SOLVED] Re: Counting input array

    Almost there...



    That's just a matter of adding an if test in the second for loop (j) to check if the allNum[number] value is 0:

    if (allNum[number] == 0)

    If the value of allNum[number] is...
  3. Replies
    17
    Views
    1,632

    [SOLVED] Re: Counting input array

    Exactly, hence

    allNum[number]++;

    Remember, allNum[number]++ can be thought of as allNum[number] = allNum[number] + 1, i.e., increment the value of allNum[number] by 1.

    Since the valid input...
  4. Replies
    17
    Views
    1,632

    [SOLVED] Re: Counting input array

    You don't need to know the amount of numbers the user wants to enter because the array is not for storing the series of numbers entered by the user. The biggest clue here is what you already have in...
  5. Replies
    17
    Views
    1,632

    [SOLVED] Re: Counting input array

    To summarise Ubiquitous' reply, you can use an ArrayList if you want. But do you have to? To answer that, find out if you can pre-determine the number of elements to initialise the array to.


    ...
  6. Replies
    17
    Views
    1,632

    [SOLVED] Re: Counting input array

    A for loop is of the form

    for (initialization; termination; increment) {
    statement(s)
    }

    The loop terminates when the termination expression evaluates to false. See The for Statement (The...
Results 1 to 6 of 6