You are viewing a single comment's thread. Return to all comments →
**JAVA **
int length = arr.size(); int countPositive = 0; int countNegative = 0; int countZeroes = 0;
for(int i : arr){ if(i > 0){ countPositive++; } else if(i < 0){ countNegative++; } else{ countZeroes++; } } double positiveRatio = (double) countPositive / length; double negativeRatio = (double) countNegative / length; double zeroRatio = (double) countZeroes / length; System.out.println(String.format("%.6f", positiveRatio)); System.out.println(String.format("%.6f", negativeRatio)); System.out.println(String.format("%.6f", zeroRatio));
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 →
**JAVA **
int length = arr.size(); int countPositive = 0; int countNegative = 0; int countZeroes = 0;