import java.util.Scanner;public class Test_Rili_Correct {public static void main( String[] args ) {String[] wd= { "日", "一", "二", "三", "四", "五", "六" };Scanner s = new Scanner(System.in);P("请输入要查询的年份:");int y = s.nextInt();P("请输入月份:");int m = s.nextInt();if(y < 1990 || y > 2016) {P("不在查询范围只内!");return;}GregorianCalendar g = new GregorianCalendar( y, m-1, 1 );P( "\n星期\t" );for ( int j = 0; j < wd.length; ++j )P( wd[j] + "\t" );P();for ( int j = 0; j < g.get( Calendar.DAY_OF_WEEK ); ++j )P( "\t" );int thisMonth = g.get( Calendar.MONTH );for ( int j = 1; j <= 31; ++j ) {int d = g.get( Calendar.DAY_OF_MONTH );P( d + "\t" );if ( g.get( Calendar.DAY_OF_WEEK ) == 7 ) {P("\n\t");}g.add( Calendar.DAY_OF_YEAR, 1 );if ( g.get( Calendar.MONDAY ) != thisMonth ) {P("\n\n");break;}}}static void P( String s ){System.out.print( s );}static void P(){System.out.println();}}
|
|