从键盘输入月份,判断月份天数
import java.util.Scanner;
public class Month{
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("请输入月份:");
int days;
int month = sc.nextInt();
if (month == 2){
days =28;
} else if (month == 4 ) {
days = 30;
} else if (month == 6 ) {
days = 30;
} else if (month == 9 ) {
days = 30;
} else if (month == 11 ) {
days = 30;
} else {
days = 31;
}
System.out.println(month + "月有" +days+ "天");
}
}