Concentration of juice after mixing n glasses in equal proportion | Java implementation of the approach ; Function to return the concentration of the resultant mixture ; Driver code
class GFG { static double mixtureConcentration ( int n , int [ ] p ) { double res = 0 ; for ( int i = 0 ; i < n ; i ++ ) res += p [ i ] ; res /= n ; return res ; } public static void main ( String [ ] args ) { int [ ] arr = { 0 , 20 , 20 } ; int n = arr . length ; System . out . println ( String . format ( " % .4f " , mixtureConcentration ( n , arr ) ) ) ; } }