package A.servicr;
import java.util.*;
public class beautifulladies {
//1.选
public void getLadies () {
List ladylist = new ArrayList<>();
Scanner input = new Scanner(System.in);
for (int i = 1; i < 4; i++) {
Lady lady =new Lady();
System.out.println("请输入第" + i + "个人的身高");
int h = input.nextInt();
lady.setHight(h);
System.out.println("请输入第" + i + "个人的体重");
int w = input.nextInt();
lady.setWight(w);
ladylist.add(lady);
}
System.out.println(ladylist);
Map<String, Integer> hightWightAvg = getHightWightAvg(ladylist);
System.out.println(hightWightAvg);
boolean result = getResult(hightWightAvg);
if (result) {
System.out.println("是");
} else {
System.out.println("不是");
}
}
//2.计算平均数字
Map<String, Integer> getHightWightAvg(List<Lady> ladies) {
int sumH = 0;int sumW=0;
for (Lady lady:ladies) {
sumH = sumH + Lady.hights;
sumW = sumW + Lady.wights;
}
System.out.println("sumH:" + sumH);
System.out.println("sumW:" + sumW);
int avgH=sumH/3;
int avgW=sumW/3;
Map<String,Integer >map=new HashMap<>();
map.put("avgH",avgH);
map.put("avgW",avgW);
return map;
}
//3.筛选数值
boolean getResult(Map<String,Integer>map){
int avgH=map.get("avgH");
int avgW=map.get("avgW");
if(avgH>150 && avgW<60){
return true;
}else{
return false;
}
}
public static void main(String[] args) {
beautifulladies beautifulladies = new beautifulladies();
beautifulladies.getLadies();
}
}