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

Unsupervised Learning

Automate Blog Post creation using Blogger APIs and Python

Setting up Python Flask server on internet via Port forwarding

Install Docker on Debian 12 (Bookworm)

Transferring Data Between PostgreSQL Docker Containers