You are viewing a single comment's thread. Return to all comments →
This is the Java code
public static void plusMinus(List arr) { // Write your code here int len=arr.size(); float posCount=0; float negCount=0; float zeroCount=0; for(int i = 0; i < len ; i++) { int elements = arr.get(i); if(elements>0){ posCount++; } else if(elements<0){ negCount++; } else{ zeroCount++; } } System.out.printf("%.6f%n",posCount/len); System.out.printf("%.6f%n",negCount/len); System.out.printf("%.6f%n",zeroCount/len);
}
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
This is the Java code
public static void plusMinus(List arr) { // Write your code here int len=arr.size(); float posCount=0; float negCount=0; float zeroCount=0; for(int i = 0; i < len ; i++) { int elements = arr.get(i); if(elements>0){ posCount++; } else if(elements<0){ negCount++; } else{ zeroCount++; } } System.out.printf("%.6f%n",posCount/len); System.out.printf("%.6f%n",negCount/len); System.out.printf("%.6f%n",zeroCount/len);
}