Hello everyone !
My program is not working how It is supposed to and I dont know why. Thanks for any feedback.
This is my task: Write the code that finds the number of array elements that are divisible by 8 in a given integer array of 10 elements specified at the input. The array elements are given one at a time, always in a new line.
And this is my solution:
import java.util.Scanner; public class JavaApp {
public static void main(String[] args) {
Scanner vstup = new Scanner(System.in);
int pole [] = new int [vstup.nextInt()];
int i;
for (i=0;i<pole.length;i++) {
pole[i]=vstup.nextInt();
}
int osem=0;
for (i=0;i<pole.length;i++) {
if (pole[i]%8==0) {
osem++;
}
}
System.out.println(osem);
} }