You are viewing a single comment's thread. Return to all comments →
public static void plusMinus(List<Integer> arr) { int countp = 0; int countn = 0; int counto = 0; int size = arr.size(); for(int i = 0; i < size; i++) { if (arr.get(i) > 0) { countp++; } else if (arr.get(i) < 0) { countn++; } else { counto++; } } double ratio1 = (double) countp / size; double ratio2 = (double) countn / size; double ratio3 = (double) counto / size; String formattedRatio1 = String.format("%.6f", ratio1); String formattedRatio2 = String.format("%.6f", ratio2); String formattedRatio3 = String.format("%.6f", ratio3);
`
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 →
`