• 作业


    1.输出的结果是什么?

    */

    import java.util.Scanner;
    public class Prs
      {
        public static void main(String[] args)
          {
            System.out.println("5+5="+5+5);
          }
      }

    2.输出自增自减

    */
    import java.util.Scanner;
    public class  Z
    {   public static void main(String[] args)
    {
      int a=3,b;

      b=a++;
      System.out.println("a="+a+",b="+b);
      }
    }


    3.算出结果

    */

    public class Shortp
      {
        ublic static void main(String[] args)
        {
          short s=3;
          s+=4;
          System.out.println("s="+s);
        }

      }

    4.输出结果是什么? 
    */

    public class LogicalRelationship
      {
        public static void main(String[] args)
        {
          System.out.println(6&3);
          System.out.println(6|3);
          System.out.println(6^3);
          System.out.println(3<<2);
          System.out.println(3>>1);
        }

      }

    5.输出结果是什么? 
    */

    public class ThreeP
      {
        public static void main(String[] args)
        {
          int x=0,y;
          y=x>1?100:200;
          System.out.println("y="+y);
        }

      }

    import java.util.Scanner;
      public class Threeb
        {
          public static void main(String[] args)
            {
              Scanner input=new Scanner(System.in);
              System.out.print("输入三个数:");
              int a=input.nextInt();
              int b=input.nextInt();
              int c=input.nextInt();
              a=a>b?a:b;
              c=a>c?a:c;
              System.out.println(c);
            }
        }

     

    6.用三元运算符做联系

    */

    {
        public static void main(String[] args)
        {
            Scanner input=new Scanner(System.in);
            int month;
            System.out.println("Enter the month ");
            month=input.nextInt();
            if(month>=3&&month<=5){
        System.out.println("This month is spring");
    }else if(month>=6&&month<=8){
        System.out.println("This month is summer");
    }else if(month>=9&&month<=11){
        System.out.println("This month is autumn");
    }else if(month==12){
        System.out.println("This month is winter");
    }else if(month>=1&&month<=2){
        System.out.println("This month is winter");
    }else{
        System.out.println("Error!");
    }
        }
    }

     

    7.使用判断语句,根据数字,输出对应季节
    */

    import java.util.Scanner;
    public class SwitchP
      {
        public static void main(String[] args)
      {
        Scanner input=new Scanner(System.in);
        System.out.print("输入一个月份:");
        int a=input.nextInt();
        if(a>=3&&a<=5)
        System.out.println("春-叶子发芽了!");
        if(a>=6&&a<=8)
        System.out.println("夏-好多叶子!");
        if(a>=9&&a<=11)
        System.out.println("秋-叶子黄了!");
        if(a>=12&&a<=2)
        System.out.println("冬-树秃顶了!");cls
      }
    }

    8.使用循环语句,分析程序的输出结果
    */

    public class Dp
    {
    public static void main(String[] args)
    {
    int x=1;
    do
    {
    System.out.println("x="+x);
    x++;
    }while(x<1);
    }
    }

  • 相关阅读:
    js 变量命名规范
    JS
    python 处理中文十六进制的encode %E9%99%88%E8%80%81%E5%B8%88/%E5%9B%BE%E7%89%87
    Pycharm 项目上传至Gitee/Github详细步骤
    Python 类型建议符, Python 定义函数的时候有冒号:
    Python 解析 JSON
    Python 解析 JSON
    Mac 安装 WordPress
    java常用书籍下载
    Docker环境搭建Redis4.0 Cluster
  • 原文地址:https://www.cnblogs.com/kongtingting/p/7709028.html
Copyright © 2020-2023  润新知