Average Salary Excluding the Minimum and Maximum Salary in Java

 Average Salary Excluding the Minimum and Maximum Salary in Java.

    public double average(int[] salary) { 

        int i; 

        int big = salary[0]; 

        int small = salary[0]; 

        double sum = salary[0]; 

        for (i = 1; i < salary.length; i++) { 

            sum += salary[i]; 

            big = (big > salary[i]) ? big : salary[i]; 

            small = (small < salary[i]) ? small : salary[i]; 

         } 

        return ((sum-big-small)/(i-2)); 

    }

Comments

Popular posts from this blog

Setting up Python Flask server on internet via Port forwarding

Supervised Learning

Automate Blog Post creation using Blogger APIs and Python

Simultaneously deploy multiple functions in a single Azure function app

Unsupervised Learning