Average of an array. Please help
Have to write a method as a part of the program that calculates average age in each Bmi group('O','U','N') The class where ages are stored is displayed below. Totally stuck...
//a class to keep data of an individual member
public class Account
{ //the attributes
private String accountName;
public double height;
public double weight;
public int age;
public double Bmiindex;
public char Bmi;
public char[] Bmicat = {'O','U','N'};
public Account(String nameIn, double heightIn, double weightIn,int ageIn)//constructor
{
accountName = nameIn;
height = heightIn;//in meters(eg. 1.60)
weight = weightIn;//in kilograms
age = ageIn;
Bmiindex = weight/(height*height);
double pp=Bmiindex;
double pt=Math.round(pp*100);
System.out.println("Your BMI is : "+pt/100);
//assigning BMI index to the appropriate category
if(Bmiindex>=25)
{
Bmi=Bmicat[0];
}
else if (Bmiindex<=20)
{
Bmi=Bmicat[1];
}
else if(Bmiindex<25&&Bmiindex>20)
{
Bmi=Bmicat[2];
}
}
//methods to read the atributes
public String getaccountName()
{
return accountName;
}
public double getHeight()
{
return height;
}
public double getWeight()
{
return weight;
}
public int getAge()
{
return age;
}
public char getBmi()
{
return Bmi;
}
public double Bmiindex()
{
return Bmiindex;
}
public char[] getBmicat()
{
return Bmicat;
}
}