importjava.util.*;publicclassShiyan{publicstaticvoidmain(String[]args){intnYear;intnMonth;Scannerinput=newScanner(System.in);System.out.println("输入年份:");intnYeat=inpu...
import java.util.*;
public class Shiyan{
public static void main(String[] args){
int nYear;
int nMonth;
Scanner input = new Scanner(System.in);
System.out.println("输入年份:");
int nYeat = input.nextInt;
System.out.print("输入月份:");
int nMonth = input.nextInt;
if(((nMonth == 2) && (((nYear%4 == 0)&&(nYear%100 != 0))||nYear%400 == 0 )) )
{
System.out.println(nYear+"年"+nMonth+"有29天");
} else if(((nMonth == 2) && (((nYear%4 != 0)&&(nYear%100 == 0))||nYear%400 != 0 ))){
System.out.println(nYear+"年"+nMonth+"有28天");
} else if((nMonth == 1)||(nMonth == 3)||(nMonth == 5)||(nMonth == 7)||(nMonth == 8)||(nMonth == 10)||(nMonth == 12)) {
System.out.println(nYear+"年"+nMonth+"有31天");
} else if((nMonth == 4)||(nMonth == 6)||(nMonth == 9)||(nMonth == 11)); {
System.out.println(nYear+"年"+nMonth+"有30天");
}else {
System.out.println("您输入的月份不正确!");
}
}
}
展开