Java程序,6、 显示出任一年份的日历(>1900)

来源:百度知道 编辑:UC知道 时间:2024/06/16 11:18:20

//////////////////////
import java.util.*;

public class MyCalendar {

private Scanner san = new Scanner(System.in);

public int readYear() {
int year;
while (true) {
try {
System.out.print("请输入查询的年份(>=1970): ");
year = Integer.parseInt(san.next());
if(year < 1970){
continue;
} else {
return (int)year;
}
} catch (Exception e) {
continue;

}
}

}

public int readMonth() {
int month;
while (true) {
try {
System.out.print("请输入查询的月份(1-12): ");
month = Integer.parseInt(san.next());
if(month <= 0 || month > 12){
continue;
} else {
return (int)month;
}
} catch (Exception e) {
continue;

}
}

}

public int readDay(int y, int m) {