Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Replies
    9
    Views
    1,724

    Re: Array and counter in for loop

    How can you detect if a fraction has already been counted? Look at the position in the array of the item being counted? Would there be any of the same fractions before it in the array?
  2. Replies
    9
    Views
    1,724

    Re: Array and counter in for loop

    You can set the size of the array large enough to hold the data.
    You need to use the number of used slots in the array to control the looping through the array.
    Remember that the max index will be...
  3. Replies
    9
    Views
    1,724

    Re: Array and counter in for loop

    Does fractions[i] have the null value? Why does the code assume it has a valid value?
    What is the value of i when the error happens? Does the array have some empty slots in it?
  4. Replies
    9
    Views
    1,724

    Re: Array and counter in for loop

    What statement has the variable with the null value? What variable has the null value?
  5. Replies
    9
    Views
    1,724

    Re: Array and counter in for loop

    Call hasNextLine() before every call to nextLine()

    Hint: the terminating condition in a for loop can have multiple sub parts:

    for(int i=0; (i < 10) && (x > 8); i++) {
Results 1 to 5 of 5