第三周作业 1802王兆明

一.
package hm;

import java.util.Scanner;

public class test3_20 {

    public static void main(String[] args) {
        Scanner r= new Scanner(System.in);
        System.out.println("输入月份");
        int a= r.nextInt();
        switch(a){
        case 1 :
        case 2 :
        case 3 :
            System.out.println("第一季度");
            break;
        case 4:
        case 5:
        case 6:
            System.out.println("第二季度");
            break;
        case 7:
        case 8:
        case 9:
            System.out.println("第三季度");
        case 10:
        case 11:
        case 12:
            System.out.println("第四季度");
            break;
        default:
                System.out.println("输入有有误");
                break;
            
            
            
        }
        r.close();
    }

}
二.
package hm;

import java.util.Scanner;

//三角形判断
public class testTriangl {

    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);
        System.out.println("输入边长x:");
        int x = r.nextInt();
                System.out.println("输入边长y:");
        int y = r.nextInt();
                System.out.println("输入边长z:");
        int z = r.nextInt();
        if((x+y>z)&&(x+z>y)&&(y+z>x)){
            System.out.println("是三角形");
        }else{
            System.out.println("不是三角形");
        }
    }

}
三.
package hm;

import java.util.Scanner;

//会员判断
public class testVIP {

    public static void main(String[] args) {
        Scanner r= new Scanner(System.in);
        System.out.println("输入会员卡号码:");
        int vip = r.nextInt();
        int lucy = vip/100%10;
        if(lucy%3==0&&vip<9999){
            System.out.println("是幸运的会员");
        }else{
            System.out.println("不是幸运会员");
        }
    }

}
四.
package hm;

import java.util.Scanner;

//输入x的值计算y值
public class testXY {

    public static void main(String[] args) {
        Scanner r= new Scanner(System.in);
        System.out.print("输入x的值:");
        int  x = r.nextInt();
        int y = 0;
        if(x>0){
            y=x + 3;
        }else if(x==0){
            y=0;
        }else if(x<0){
            y=x*2-1;
        }
        System.out.print("y的值是:"+y);
    }

}
五.
package hm;
//闰年判断
import java.util.Scanner;

public class testYear {

    public static void main(String[] args) {
        Scanner r= new Scanner(System.in);
        System.out.println("输入年份");
        int year = r.nextInt();
        if((year%4==0 && year%100!=0)||year%400==0){
            System.out.println("是润年");
        }else{
            System.out.println("不是润年");
        }
    }

}

 

你可能感兴趣的:(第三周作业 1802王兆明)