Java练习


编写一个计算某个月份天数的程序,根据用户输入的月份,判断并输出该月份包含的天数。
package yue;
import java.util.Scanner;
public class yue {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入一个月份:"); //输入月份
int month = input.nextInt();
if(month==2)
{
System.out.println(month+"月闰年是29天,不是闰年则是28天");
}
else if(month==4||month==6||month==9||month==11)
{
System.out.println(month+"月是30天");
}
else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
System.out.println(month+"月是31天");
}
}
}


