package people;
public class People {
public double height;
public double weight;
public People(double height ,double weight){
this.height=height;
this.weight=weight;
}
public void speakHello(){
System.out.println("Hello!!!");
}
public void averageHeight(People[] people){
double temp=0.0;
for(int i=0;i<people.length;i++){
temp=temp+people[i].height;
}
temp=(temp+this.height)/(people.length+1);
System.out.println("所有人的平均身高为:"+temp);
}
public void averageHeight(People people){
double temp=0.0;
temp=(people.height+this.height)/2;
System.out.println("两人平均身高为:"+temp);
}
public void averageWeight(People[] people){
double temp=0.0;
for(int i=0;i<people.length;i++){
temp=temp+people[i].weight;
}
temp=(temp+this.weight)/(people.length+1);
System.out.println("所有人平均体重为:"+temp);
}
public void averageWeight(People people){
double temp=0.0;
temp=(people.weight+this.weight)/2;
System.out.println("两人平均体重为:"+temp);
}
}
People
最新推荐文章于 2022-12-26 13:16:04 发布