Java Array Average avg(float... numbers)

Here you can find the source of avg(float... numbers)

Description

avg

License

Open Source License

Declaration

public static float avg(float... numbers) 

Method Source Code

//package com.java2s;
/*===========================================================================
COPYRIGHT 2013 Vin?cius G. Mendon?a ALL RIGHTS RESERVED.
    //from  w  ww  .j  av  a 2  s. co m
This software cannot be copied, stored, distributed without
Vin?cius G. Mendon?a prior authorization.
    
This file was made available on https://github.com/ViniGodoy and it
is free to be redistributed or used under Creative Commons license 2.5 br:
http://creativecommons.org/licenses/by-sa/2.5/br/
============================================================================*/

public class Main {
    public static float avg(float... numbers) {
        return sum(numbers) / numbers.length;
    }

    public static float sum(float... numbers) {
        float sum = 0;
        for (float number : numbers)
            sum += number;
        return sum;
    }
}

Related

  1. avg(double[] values)
  2. avg(double[] values)
  3. avg(double[] x, int start, int end)
  4. avg(final double a, final double b)
  5. avg(final double... values)
  6. avg(int... values)
  7. avg(int[] arr)
  8. avg(int[] values)
  9. avg(int[] xs)