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
Type: Posts; User: Norm
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
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 >...
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...
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...
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...
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.
@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...
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
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...
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:...
Please copy the full text of the error messages and paste it here.