JAVA基础1-美女
输入美女的身高体重来判断是否属于美女
主要代码
先设置一个girl类
public class Girl {
private int high;
private int weight;
public int getHigh() {
return high;
}
public void setHigh(int high) {
this.high = high;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
@Override
public String toString() {
return "Girl{" +
"high=" + high +
", weight=" + weight +
'}';
}
}
实现功能
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
List girlList =new ArrayList<>();
for(int i=1;i<4;i++){
Girl girl = new Girl();
System.out.println(“请输入第”+i+“个美女的身高:”);
int h=scanner.nextInt();
girl.setHigh(h);
System.out.println(“请输入第”+i+“个美女的体重: