import java.util.*;
import static java.
lang.
System.
*;
class Koyomi2 {
public static void main
(String[] args
) { Scanner scan = new Scanner(in);
cal.setTime(today);
int day
= cal.
get(Calendar.
DAY_OF_MONTH); out.println("今日は" + yearNow + "年" + (monthNow + 1) + "月" + day + "日です。");
while(true) {
out.print("何年のカレンダーを見ますか?2000~2040までの数字を入力して下さい。>");
yearStr = scan.next();
if (yearStr.matches("20[0-3][0-9]") || yearStr.matches("2040")) {
break;
}
out.println("正しい入力ではありません。");
}
int year
= Integer.
parseInt(yearStr
); boolean isUruu = false;
if (year % 400 == 0) {
isUruu = true;
} else if (year % 100 == 0) {
isUruu = false;
} else if (year % 4 == 0) {
isUruu = true;
} else {
isUruu = false;
}
while(true) {
out.print("何月のカレンダーを見ますか?1~12までの数字を入力して下さい。>");
monthStr = scan.next();
if (monthStr.matches("[1-9]") || monthStr.matches("[1][0-2]")) {
break;
}
out.println("正しい入力ではありません。");
}
int month
= Integer.
parseInt(monthStr
) - 1; out.println(" " + year + "年 " + (month + 1) + "月");
out.println("日 月 火 水 木 金 土");
int youbi
= cal2.
get(Calendar.
DAY_OF_WEEK); boolean isDaigetsu = false;
boolean isShogetsu = false;
if (month == 1 - 1 || month == 3 - 1 || month == 5 - 1 || month == 7 - 1
|| month == 8 - 1 || month == 10 - 1 || month == 12 - 1) {
isDaigetsu = true;
}
if (month == 4 - 1 || month == 6 - 1 || month == 9 - 1 || month == 11 - 1) {
isShogetsu = true;
}
if (youbi == 1) {
out.print(" 1 2 3 4 5 6 7\n"
+ " 8 9 10 11 12 13 14\n"
+ "15 16 17 18 19 20 21\n"
+ "22 23 24 25 26 27 28");
if (isDaigetsu) {
out.println("\n29 30 31");
}
if (isShogetsu) {
out.println("\n29 30");
}
if (isUruu && month == 2 - 1) {
out.println("\n29");
}
} else if (youbi == 2) {
out.print(" 1 2 3 4 5 6\n"
+ " 7 8 9 10 11 12 13\n"
+ "14 15 16 17 18 19 20\n"
+ "21 22 23 24 25 26 27\n"
+ "28");
if (isDaigetsu) {
out.println(" 29 30 31");
}
if (isShogetsu) {
out.println(" 29 30");
}
if (isUruu && month == 2 - 1) {
out.println(" 29");
}
} else if (youbi == 3) {
out.print(" 1 2 3 4 5\n"
+ " 6 7 8 9 10 11 12\n"
+ "13 14 15 16 17 18 19\n"
+ "20 21 22 23 24 25 26\n"
+ "27 28");
if (isDaigetsu) {
out.println(" 29 30 31");
}
if (isShogetsu) {
out.println(" 29 30");
}
if (isUruu && month == 2 - 1) {
out.println(" 29");
}
} else if (youbi == 4) {
out.print(" 1 2 3 4\n"
+ " 5 6 7 8 9 10 11\n"
+ "12 13 14 15 16 17 18\n"
+ "19 20 21 22 23 24 25\n"
+ "26 27 28");
if (isDaigetsu) {
out.println(" 29 30 31");
}
if (isShogetsu) {
out.println(" 29 30");
}
if (isUruu && month == 2 - 1) {
out.println(" 29");
}
} else if (youbi == 5) {
out.print(" 1 2 3\n"
+ " 4 5 6 7 8 9 10\n"
+ "11 12 13 14 15 16 17\n"
+ "18 19 20 21 22 23 24\n"
+ "25 26 27 28");
if (isDaigetsu) {
out.println(" 29 30 31");
}
if (isShogetsu) {
out.println(" 29 30");
}
if (isUruu && month == 2 - 1) {
out.println(" 29");
}
} else if (youbi == 6) {
out.print(" 1 2\n"
+ " 3 4 5 6 7 8 9\n"
+ "10 11 12 13 14 15 16\n"
+ "17 18 19 20 21 22 23\n"
+ "24 25 26 27 28");
if (isDaigetsu) {
out.println(" 29 30\n31");
}
if (isShogetsu) {
out.println(" 29 30");
}
if (isUruu && month == 2 - 1) {
out.println(" 29");
}
} else if (youbi == 7) {
out.print(" 1\n"
+ " 2 3 4 5 6 7 8\n"
+ " 9 10 11 12 13 14 15\n"
+ "16 17 18 19 20 21 22\n"
+ "23 24 25 26 27 28");
if (isDaigetsu) {
out.println(" 29\n30 31");
}
if (isShogetsu) {
out.println(" 29\n30");
}
if (isUruu && month == 2 - 1) {
out.println("29");
}
} else {}
}
}