JAVA上机实训题

来源:百度知道 编辑:UC知道 时间:2024/05/30 07:49:33
实现一个万年历,要求从键盘输入一个日期,然后计算出该日期是星期几。
希望高手帮忙,把代码贴上来

饿 我今天才弄好的 应该和你的差不多 你自己看
import java.util.*;

public class rili {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);
int year;
int month;
int firstDay;
int day = 0;
int sum = 0;
int week;
int num = 0;

System.out.println("**********************欢迎使用万年历**********************\n\n");
System.out.print("请选择年份:");
year = input.nextInt();

boolean isRn = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;

System.out.print("\n请选择月份:");

do {
month = input.nextInt();

if (month > 12) {
System.out.print("输入错误请从新输入:");

}
} while (month > 12);

switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day = 31;
brea