版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、import game.Test;import java.util.*;public class Calendar1 public int days = 36525;public int monthsDay = 1;public int years = 2000;public int yearDay = 0;public String week = , answer = ;public Date date=new Date();public String time=;public String work = new String255;/事件的内容public int workyear = n
2、ew int255;/事件的年份public int workmonth = new int255;/事件的月份public int workday = new int255;/事件的日期public int day, No = 0, No1 = 0;/附加参数public int no =0;public int weekday;Scanner input = new Scanner(System.in);/* * 标题 */public void start()System.out/标题.println(n 欢迎使用我行我速万年历nttQQ727229775nn1.浏览下月输入【】t2.浏
3、览上月输入【】n3.浏览去年输入【】t4.浏览明年输入【】n5.重新开始输入【】t6.退出程序输入【】n7.添加记事输入【】t8.浏览/删除全部记事【】n9.删除/修改记事【】t10.菜单提示【】n11.显示当前时间【T】n);menu();/* * 计算总天数(days) */public void count()for (int month = 1; month monthsDay; month+) if (month = 1 | month = 3 | month = 5 | month = 7| month = 8 | month = 10 | month = 12) days +=
4、31;yearDay = 31; else if (month = 2) if (years % 4 = 0 & years % 100 != 0| years % 400 = 0) days += 29;yearDay = 29; else days += 28;yearDay = 28; else if (month = 4 | month = 6 | month = 9| month = 11) days += 30;yearDay = 30;if (monthsDay = 1 | monthsDay = 3 | monthsDay = 5| monthsDay = 7 | months
5、Day = 8 | monthsDay = 10| monthsDay = 12) yearDay = 31; else if (monthsDay = 2) if (years % 4 = 0 & years % 100 != 0 | years % 400 = 0) yearDay = 29; else yearDay = 28; else if (monthsDay = 4 | monthsDay = 6 | monthsDay = 9| monthsDay = 11) yearDay = 30;/计算当前月的天数week();/把当前星期表示的数字改为中文show();/显示日历/*
6、* 输入初始值 */public void fate()trydays = 0;System.out.print(nn输入年份:);/计算1900-?的天数years = input.nextInt();for (int year = 1900; year 12 | monthsDay 1) /提示输入错误System.out.println(输入月份错误,请重新输入!);continue; else break;catch(Exception ex)System.out.println(ntt检测到输入异常,跳转到菜单输入。);years=2000;monthsDay=1;count();/
7、* * 把当前星期所表示的数字改为中文 */public void week()weekday = (days + 1) % 7;/把当前星期所表示的数字改为中文switch (weekday) case 0:week = 日;break;case 1:week = 一;break;case 2:week = 二;break;case 3:week = 三;break;case 4:week = 四;break;case 5:week = 五;break;case 6:week = 六;break;System.out.print(n这个月的第一天是:星期 + week);/计算当月第一天是星
8、期几/* * 显示当月万年历 */public void show()System.out.print(nn星期天t星期一t星期二t星期三t星期四t星期五t星期六n);for (int a = 1; a = weekday; a+) System.out.print(t);for (day = 1; day = yearDay; day+) System.out.print(day + t);/计算星期六的日期if (days + day) % 7 = 6) System.out.println();feast();/显示当月节日/* * 显示当月节日 */public void feast(
9、)switch (monthsDay) /显示节日case 1:System.out.println(n + monthsDay + .1:元旦);break;case 2:System.out.println(n + monthsDay + .14:情人节 + n+ monthsDay + .28:元宵节);break;case 3:System.out.println(n + monthsDay + .8:妇女节);break;case 4:System.out.println(n + monthsDay + .5:清明节);break;case 5:System.out.println(
10、n + monthsDay + .1:劳动节n+ monthsDay + .4:青年节);break;case 6:System.out.println(n + monthsDay + .1:儿童节n+ monthsDay + .16:端午节);break;case 7:System.out.println(n + monthsDay + .1:建党节);break;case 8:System.out.println(n + monthsDay + .1:建军节 + n+ monthsDay + .16:七夕);break;case 9:System.out.println(n + month
11、sDay + .10:教师节 + n+ monthsDay + .22:中秋节);break;case 10:System.out.println(n + monthsDay + .1:国庆节);break;case 11:System.out.println(n无);break;case 12:System.out.println(n无);break;job();/* * 显示当月记事 */public void job()No = 0;while (No 254) /显示当月记事if (workNo != null & workyearNo = years& monthsDay = wor
12、kmonthNo & No = 12) monthsDay = 1;years += 1;System.out.println(days); else monthsDay += 1;days=0;for (int year = 1900; year years; year+) if (year % 4 = 0 & year % 100 != 0 | year % 400 = 0) days += 366; else days += 365;count();/开始返回计算天数/* * 浏览上个月 */public void ultimo()if (monthsDay = 1) monthsDay
13、 = 12;years -= 1; else monthsDay -= 1;days=0;for (int year = 1900; year years; year+) if (year % 4 = 0 & year % 100 != 0 | year % 400 = 0) days += 366; else days += 365;count();/开始返回计算天数/* * 浏览去年(12个月前)日历 */public void lastYear()years -= 1;days=0;for (int year = 1900; year years; year+) if (year % 4
14、 = 0 & year % 100 != 0 | year % 400 = 0) days += 366; else days += 365;count();/开始返回计算天数/* * 浏览明年(12个月后)日历 */public void nextYear()years += 1;days=0;for (int year = 1900; year = 2500 | workyear2 = 1900) System.out.println(n输入年份格式错误,请重新输入!);continue;System.out.println(修改记事月份为:);int workmonth2 = input
15、.nextInt();if (workmonth2 = 13) System.out.println(n输入月份格式错误,请重新输入!);continue;workmonthno = workmonth2;System.out.println(修改记事日期为:);int workday2 = input.nextInt();if (workday2 = 32) System.out.println(n输入日期格式错误,请重新输入!);continue;workdayno = workday2;System.out.println(修改记事内容为:);String work2 = input.n
16、ext();workno = work2;System.out.println(修改记事完毕!);workmonth2 = 0;workyear2 = 0;workday2 = 0;work2 = null;no = 0;menu();/切换到主菜单catch(Exception ex)System.out.println(ntt检测到输入异常,跳转到菜单输入。); else if (answer2.equals(N)/删除记事| answer2.equals(n) System.out.print(请输入需要删除的记事号码:No.);tryno = input.nextInt();catch
17、(Exception ex)System.out.println(ntt检测到输入异常,跳转到菜单输入。);if (workno = null) /搜索有无此记事System.out.println(无此编号记事!退出删除程序);menu();/切换到主菜单System.out.println(记事:(日期: + workyearno+ 年 + workmonthno + 月+ workdayno + 日 + )n内容:【+ workno + 】 + t编号:No. + no);System.out.println(确定删除(Y/N)?);String answer3 = input.next
18、();if (answer3.equals(Y) | answer3.equals(y) /提示是否删除workmonthno = 0;workyearno = 0;workdayno = 0;workno = null;no = 0;answer3 = null;answer2 = null;System.out.print(该号码记事已删除!);menu();/切换到主菜单 else answer3 = null;answer2 = null;menu();/切换到主菜单 else answer2 = null;menu();/切换到主菜单/* * 显示当前时间 */public void
19、 Date()System.out.println(当前时间为:+time.format(%tH,date)+:+time.format(%tM,date)+:+time.format(%tS,date)+nt+time.format(%tF,date)+,+time.format(%tA,date);/* * 添加新记事 */public void append()while (No = 2500| workyearNo = 1900) System.out.println(n输入年份格式错误,请重新输入!);continue;System.out.print(n请输入想添加记事的月份(1-
20、12):);/输入月份workmonthNo = input.nextInt();if (workmonthNo = 13) System.out.println(n输入月份格式错误,请重新输入!);continue;System.out.print(n请输入想添加记事的日期(1-31):);/输入日期workdayNo = input.nextInt();if (workdayNo = 32) System.out.println(n输入日期格式错误,请重新输入!);continue;System.out.print(n请输入记事内容:);/输入内容workNo = input.next();System.out.println(添加完毕!创建记事:n + 时间:/显示添加信息+ workyearNo + 年 + workmonthNo+ 月 + workdayNo + 日n【 + workNo+ 】t位于:No. + No);if (workyearNo != 0) No+;menu();/切换到主菜单 else No+;continue;catch(Exception ex)System.out.println(ntt检测
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 文化定制服务合同范本
- 水库出租转让合同范本
- 文明施工协议书模板
- 木工工人合同协议书
- 水产养殖招商合同范本
- 外卖骑手招聘考试监考试题及答案
- 跆拳道比赛现场急救技能竞赛试题及答案
- 民航货物运输实训试题带答案
- 教师安全驾驶协议书
- 氢气储罐防腐合同协议
- GJB573B-2020 引信及引信零部件环境与性能试验方法
- 2025年上海市新合同范本:劳动合同书模板
- 华为质量管理体系课件
- 期货交易分析法解读
- 薪酬绩效主管述职汇报
- 危化品拆除工程施工方案
- 2025年《中国公民健康素养66条》知识考试题库(附答案)
- 生态文明教育在初中生物教学中的有效途径与策略探究
- 呼兰河传教学课件
- 传染病四项检测与诊断标准
- 吹膜机操作规程
评论
0/150
提交评论