ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

作业2

2021-01-27 23:58:41  阅读:12  来源: 互联网

标签:int 作业 System static println public out


public class work1 {
    static int level = 15;
    //类变量 属于work1 随类消失
    String name = "花木兰";
    //实例变量 从属于对象
     public static void main(String[] args) {

         int i=0;
         //局部变量 类的方法中的变量
     }
}
public class work2 {
    static double i;
 
    public static void main(String[] args) {
        System.out.println(i);

    }
}

在这里插入图片描述
3.

public class work3 {
    static final int damage=300;
    
    public static void main(String[] args) {
        System.out.println(damage);

    }
}

public class work4 {

    public static void main(String[] args) {
        int i=1;
        int j=1;
        int result;
        while(i<=9){
            j=1;
            while(j<=i){
                result=i*j;
                System.out.print(j+"*"+i+"="+result+"\t");
                j++;
            }
            i++;
            System.out.println("");
        }

    }
public class work4 {


public static void main(String[] args) {

    for(int i=1;i<=9;i++){
        for(int j=1;j<=i;j++){
            System.out.print(j+"*"+i+"="+i*j+"\t");
          
        }
        System.out.println();
    }

}
}

在这里插入图片描述

public class work5 {
    public static void main(String[] args) {

        int age=18;
        double height=1.72;
        double weight=55.0;
        double BMI;
        BMI = 0.1*weight/(height*height);
        System.out.println(age);
        System.out.println(BMI);
        System.out.println(age==18);
        System.out.println(age<15);
        System.out.println(age!=20);
      int score=90;
      int hege=60;
      String level=score>hege?"达标":"不达标";
        System.out.println(level);

    }
}

标签:int,作业,System,static,println,public,out
来源: https://blog.csdn.net/m0_52324197/article/details/113280346

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有