码迷,mamicode.com
首页 > 其他好文 > 详细

国庆作业

时间:2017-10-09 14:17:32      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:class   ext   main   switch   cas   util   out   str   ring   

import java.util.Scanner;
public class L

{

    public static void main(String[] args)

{
        System.out.println("5+5="+5+5);
       
        int a=3,b;
        b=a++;
        System.out.println("a="+a+",b="+b);
       
        short c=3;
        c=(short) (c+4);
        System.out.println("c="+c);
       
        short d=3;
        d+=4;
        System.out.println("d="+d);
       
        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);
       
        int e=0,f;
        f=e>1?100:200;
        System.out.println("f="+f);
       
        @SuppressWarnings("resource")
        Scanner input=new Scanner(System.in);
        int g,h;
        System.out.println("Enter the g ");
        g=input.nextInt();
        System.out.println("Enter the h ");
        h=input.nextInt();
        h=g>h?g:h;
        System.out.println("The larger of the two numbers is"+h);
       
        @SuppressWarnings("resource")
        Scanner input1=new Scanner(System.in);
        int x,y,z;
        System.out.println("Enter the x ");
        x=input1.nextInt();
        System.out.println("Enter the y ");
        y=input1.nextInt();
        System.out.println("Enter the z ");
        z=input1.nextInt();
        y=x>y?x:y;
        z=y>z?y:z;
        System.out.println("The largest of the three numbers is"+ z);
       
        @SuppressWarnings("resource")
        Scanner input11=new Scanner(System.in);
        int month;
        System.out.println("Enter the month ");
        month=input11.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!");
                }
       
        @SuppressWarnings("resource")
        Scanner input111=new Scanner(System.in);
        int month1;
        System.out.println("Enter the month ");
        month1=input111.nextInt();
        switch (month1)
        {
        case 1: case 2: case 12:
            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;
        }
   
        int i=1;
        do{
            System.out.println("i="+i);
            i++;
            }while(i<1);
       
        int j=1;
        while(j<1){
            System.out.println("j="+j);
            j++;
            }
       
        for(int k=1;k<3;k++)
        {
        System.out.println("k="+k);
        }
       
        int q=1;
        for(System.out.println("a");q<3;System.out.println("c"))
            {
            System.out.println("d");
            q++;
            }
    }
}

国庆作业

标签:class   ext   main   switch   cas   util   out   str   ring   

原文地址:http://www.cnblogs.com/hhr1998/p/7640555.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!