Plus Minus

  • + 0 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);

    }
    

    }