Plus Minus

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