注册 登录
查看: 1646|回复: 0
打印 上一主题 下一主题

英文作业: 计算闰年 并计算2月29号星期几 下一个 闰年是什么时候

[复制链接]

该用户从未签到

3524

主题

3538

帖子

67万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
673178
QQ
跳转到指定楼层
楼主
发表于 2018-10-25 21:17:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Assignment #6
Goals:
Ø This lab gives students more experience in
· Top-down design
· Procedural abstraction using methods.
Background Information
A year with 366 days is called a leap year.  A year is a leap year if it is divisible by 4 (For example, 1996), except that it is not a leap year if it is divisible by 100 (For example, 1900); however, it is a leap year if it is divisible by 400 (for example, 2000); and there were no leap years before the introduction of the Gregorian Calendar on October 15, 1582.
Requirement:
Design an algorithm, and then write the java program to ask the user to enter a year greater than 1582. Your program then displays the following:
· If the year is a leap year or not.
· If the given year is a leap year, your program should then display
1. which day of the week was Feb 29th, and
2. the next leap year where Feb. 29th happens on the same week day.
The following is a screen sample of the program:
        Please enter a year greater than 1582: 2013
           Year 2013 is not a leap year.
        Do you want to repeat the program: yes
        Please enter a year greater than 1582: 2000
         
               Year 200 is a leap year
           Feb 29, 2000 is on Tuesday
              The next leap year where Feb 29 is on Tuesday is year 2028
Do you want to repeat the program: no
Program terminates
NOTE:
Use the following algorithm, known as Zeller’s Congruence, to compute a single digit, 0 to 6, for Sunday through Saturday.   For example, 22/10/1999 has occurred on Friday so the zellers(1999, 10, 22) returns 5 representing Friday.
Zeller’s Algorithm
          Define Terms
0.1 Given the YEAR, MONTH and DAY, representing a date.
0.2 Let DayNumber be the an integer number representing the day of the week( 0 represents Sunday, 6 represents Saturday)
0.3 Let StartMonth, StartYear, and LeapFactor be three integer variables used in the calculation
        Start
   1.  IF MONTH < 3  
                1.1 StartMonth = 0
                1.2 StartYear   = YEAR – 1
                                
                   OTHERWISE
1.3 StartMonth = INT (0.4 * MONTH + 2.3)
1.4 StartYear   = YEAR
           2. LeapFactor = (StartYear / 4) – (StartYear / 100) + (StartYear / 400)
3. RETURN  DayNumber = ((365 * YEAR  + 31 * (MONTH  – 1) + DAY +  
                                               LeapFactor – StartMonth) – 1) MOD 7
Marking Scheme
[2 marks] Presentation/Style: Organization, readability, descriptive
                           identifier, indentation, bracket placement.
[14 marks] Correctness: Program works without bugs.
                Appropriate use of methods.
           [4 marks] Documentation: External (pseudo code for your main method
                          only) and Internal

此源码经过详细测试 保证能运行!!!


下载地址:
游客,本付费内容需要支付 100金币 才能浏览支付

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
java无忧网(http://www.javawyw.com),专业提供Java大作业,小作业,课程设计,毕业设计源码,答辩辅导,作业排错,bug修复,专业解答,远程部署运行项目等服务
本网站所有源码,保证能运行!
QQ:1399491757
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回列表 返回顶部