8.5java first lesson record post

Novice java entry.
Now that you are learning java, the first warm-up is the nine-nine multiplication table, as follows:
insert image description here
The second warm-up is to judge whether Xiaohua is an animal.

public class test1 {
    public static void main(String[] args){
        an xiaohua=new an();
        xiaohua.legs=2;
        xiaohua.say=false;
        if(xiaohua.legs ==4 && !xiaohua.say ){
            System.out.println("xiaohua是小狗"); }
        else {
            System.out.println("不是小狗");
        }
    }
}

Next is our key content: beauty selection concubine.

import javax.xml.transform.Result;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class beautifulladies<main> {
    //1.从我们的宁波财经学院选十个美女 权限修饰符 public private...
    void getLadies(){
      List<Integer> hights=new ArrayList<>();
      List<Integer> wights=new ArrayList<>();
      hights.add(180);
      hights.add(150);
      hights.add(155);
      wights.add(55);
      wights.add(50);
      wights.add(70);
      System.out.println(hights);
      System.out.println(wights);
      getHightWightAvg(hights,wights);
      Map<String,Integer> hightWightAvg = getHightWightAvg(hights, wights);
      System.out.println(hightWightAvg);
      boolean result=getResult(hightWightAvg);
        if (result){
            System.out.println("是美女"); }
            else {
            System.out.println("不是美女"); }
        }

    //2.计算美女的平均身高和体重
    Map<String,Integer> getHightWightAvg( List<Integer> hights,List<Integer> wights){
        int sumH=0;
        for(int h:hights){
            sumH=sumH+h;
        }
        int sumW=0;
        for(int w:wights){
            sumW=sumW+w;
        }
        System.out.println("sumH:"+sumH);
        System.out.println("sumW:"+sumW);
        int avgH=sumH/3;
        int avgW=sumW/3;
        System.out.println("avgH:"+avgH);
        System.out.println("avgW:"+avgW);
        Map<String,Integer> map=new HashMap<>();
        map.put("avgH",avgH);
        map.put("avgW",avgW);
        return map;
    }
    //3.判断平均身高>150 体重<60
    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();
   }
}

Guess you like

Origin blog.csdn.net/zlc2351951436/article/details/98668149