It is necessary to count the number of positive, negative and equal to 0 elements, but the code gives the number of elements in the array. Moreover, the answer 8 is displayed in the one with, where the condition: num [i]> 0 What is my problem? ..
public class test { public static void main (String[] args){ int[] a={-10,0,5,0,2,8,3,-1}; task11(a); } static void task11(int[] num){ int c1=0, c2=0, c3=0; for ( int i=0; i<num.length; i++){ if(num[i]>0 && num[i]!=0){ c1=c1+1; } else if (num[i]<0 ){ c2=c2+1; } else if (num[i]==0){ c3=c3+1; }} System.out.println("Положительных чисел: "+c1+"; Отрицательных: "+c2+"; Равных нулю :"+c3); } } Answer: Positive numbers: 8; Negatives: 0; Equal to zero: 0