Plus Minus

  • + 0 comments
    # 
    
    public static void main(String[] args) {
       double add= 0;
        double sub=0;
        double zero=0;
        Scanner sc =new Scanner(System.in);
        // System.out.println("Enter the no of elements");
        int n =sc.nextInt();    
        int [] arr= new int[n];
        // System.out.println("Enter the elements");
    
    
        for(int i=0;i<arr.length;i++) {
            arr[i]=sc.nextInt();
            if (arr[i]>=1 && arr[i]<=100) {
                add+=1;
            }
            if (arr[i]<=-1 && arr[i]>=-100) {
                sub+=1;
            }
            if (arr[i]==0) {
                zero+=1;
            }
    
          }
        float n1 = n;
    
       System.out.printf("%.6f%n",add/n1);
       System.out.printf("%.6f%n",sub/n1);
       System.out.printf("%.6f%n",zero/n1);
    
        sc.close();
    }
    

    }