Search:

Type: Posts; User: Norm

Search: Search took 0.19 seconds.

  1. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    from post#12

    abc[x]=Integer.parseInt(br.readLine()); // Save value in an array element

    ....
    if(abc[x]%2==1) // test the value of an array element
  2. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    Use the elements from the array like in post#12 and not the variable that the user's input is being read into.

    Look at how to use arrays: Arrays (The Java™ Tutorials > Learning the Java Language >...
  3. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    Slow down and look at what the program outputs and then look at the code to see why.
    Look at the last number you entered and what the sum was:

    Or look at the last number you entered and what was...
  4. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    Look at what value is being printed for the "even indexes" loop? Is that the value you want to see?
    Same with the next loop. What is in abc1?

    Look at the code in post#12 for getting the values...
  5. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    Thats strange. I get this when I execute the code. I've changed the code to take its input from a String vs console:


    If you have changed the code, you need to post the code you are working...
  6. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    Can you explain what the problem is? Post the program's output and add some comments saying what is wrong and show what the output should be.
  7. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    @JanAlbertLam Please post the current version of the code you are working with so we can be sure we are working with the same code. I get errors on the line I posted and don't understand why you do...
  8. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    Your compiler should give you error messages on this line:

    int abc[15], tot=0, n_count=1;


    What is printed out on the console when you enter:
    javac -version

    I get: javac 1.7.0
  9. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    When I compile the posted code I get several errors on the line in my post. I was wondering why you didn't get those errors and include them in your post. What version of the javac command are you...
  10. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    You left off the other error messages on this line:

    int abc[15], tot=0, n_count=1;


    See the tutorial for how to define an array:...
  11. Replies
    26
    Views
    758

    Re: WHAT'S THE RIGHT CODES FOR ACCESSING ARRAYS?

    Please copy the full text of the error messages and paste it here.
Results 1 to 11 of 11