You are viewing a single comment's thread. Return to all comments →
**Java **
**Java** public static void plusMinus(List<Integer> arr) { int positive=0, negative=0, zero=0; for (Integer integer : arr) { if(integer>0){ positive= positive+1; }else if(integer<0){ negative=negative+1; }else zero=zero+1; } BigDecimal size = new BigDecimal(arr.size()); BigDecimal p = new BigDecimal(positive); System.out.println(p.divide(size, 5, RoundingMode.CEILING)); BigDecimal n = new BigDecimal(negative); System.out.println(n.divide(size, 5, RoundingMode.CEILING)); BigDecimal z = new BigDecimal(zero); System.out.println(z.divide(size, 5, RoundingMode.CEILING)); } }
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 **