You are viewing a single comment's thread. Return to all comments →
here is a solutions with java
int zeros = 0; int positives = 0; int negatives = 0;
for(int numbers : arr){ if(numbers == 0){ positives ++; }else if(numbers < 0){ negatives ++; }else{ zeros++; } } int total = arr.size(); double proportionPositives = (double) positives / total; double proportionNegatives = (double) negatives/ total; double proportionzeros = (double) zeros / total; System.out.printf("%.6f\n", proportionzeros); System.out.printf("%.6f\n", proportionNegatives); System.out.printf("%.6f\n", proportionPositives);
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 →
here is a solutions with java
int zeros = 0; int positives = 0; int negatives = 0;