zoukankan      html  css  js  c++  java
  • 9.25作业--林枫

    class Demo_01 
    {
        public static void main(String[] args) 
        {
            System.out.println("5+5="+5+5);
        }
    }

    class Demo_02 
    {
        public static void main(String[] args) 
        {
            int a=3,b;
            b=a++;
            System.out.println("a="+a+",b="+b);
        }
    }

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

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

    class Demo_04 
    {
        public static void main(String[] args) 
        {
            System.out.println(6&3);
        }
    }

     class Demo_04 
    {
        public static void main(String[] args) 
        {
            System.out.println(6|3);
        }
    }

    class Demo_04 
    {
        public static void main(String[] args) 
        {
            System.out.println(6^3);
        }
    }

     class Demo_04 
    {
        public static void main(String[] args) 
        {
            System.out.println(3<<2);
        }
    }

    class Demo_04 
    {
        public static void main(String[] args) 
        {
            System.out.println(3>>1);
        }
    }

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

     import java.util.Scanner;
    class Demo_05
    {
        public static void main(String[] args)
        {
            Scanner input=new Scanner(System.in);
            int x,y;
            System.out.println("Enter the x ");
            x=input.nextInt();
            System.out.println("Enter the y ");
            y=input.nextInt();
            y=x>y?x:y;
            System.out.println("The larger of the two numbers is"+y);
        }
    }

    import java.util.Scanner;
    class Demo_05
    {
        public static void main(String[] args)
        {
            Scanner input=new Scanner(System.in);
            int x,y,z;
            System.out.println("Enter the x ");
            x=input.nextInt();
            System.out.println("Enter the y ");
            y=input.nextInt();
            System.out.println("Enter the z ");
            z=input.nextInt();
            y=x>y?x:y;
            z=y>z?y:z;
            System.out.println("The largest of the three numbers is"+ z);
        }
    }

     import java.util.Scanner;
    class Demo_06
    {
        public static void main(String[] args)
        {
            Scanner input=new Scanner(System.in);
            int weekDay;
            System.out.println("Enter the weekDay ");
            weekDay=input.nextInt();
            if(weekDay==1){
        System.out.println("Today is Monday");
    }else if(weekDay==2){
        System.out.println("Today is Tuesday");
    }else if(weekDay==3){
        System.out.println("Today is Wednesday");
    }else if(weekDay==4){
        System.out.println("Today is Thursday");
    }else if(weekDay==5){
        System.out.println("Today is Friday");
    }else if(weekDay==6){
        System.out.println("Today is Saturday");
    }else if(weekDay==7){
        System.out.println("Today is Sunday");
    }else{
        System.out.println("Error!");
    }
        }
    }

     import java.util.Scanner;
    class Demo_06
    {
        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!");
    }
        }
    }

    import java.util.Scanner;
    class Demo_07
    {
    public static void main(String[] args)
    {
    Scanner input=new Scanner(System.in);
    int month;
    System.out.println("Enter the month ");
    month=input.nextInt();
    switch (month)
    {
    case 12: case 1: case 2:
    System.out.println("This month is winter");
    break;
    case 3: case 4: case 5:
    System.out.println("This month is spring");
    break;
    case 6:case 7:case 8:
    System.out.println("This month is summer");
    break;
    case 9:case 10:case 11:
    System.out.println("This month is autumn");
    break;
    default:
    System.out.println("Error!");
    break;
    }
    }
    }

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

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

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

    class Demo_09
    {
        public static void main(String[] args)
        {
            int x=1;
            for(System.out.println("a");x<3;System.out.println("c"))
                {
                System.out.println("d");
                x++;
                }
        }
    }

  • 相关阅读:
    cocos2dx的发展的例子2048(加入动画版)
    Hibernate操作Clob数据类型
    json级联城市
    Ubuntu Linux 永山(mount)分
    C++出现计算机术语5
    Cocos2d-x 3.0 红孩儿私人义务教育
    大页(huge pages) 三大系列 ---计算大页配置参数
    EJB_消息驱动发展bean
    HDU5086Revenge of Segment Tree(数论)
    第五章_JSTL
  • 原文地址:https://www.cnblogs.com/linfenglf/p/7617604.html
Copyright © 2011-2022 走看看