A leap year test program that detects whether the input is legitimate

Source: Internet
Author: User

1, leap years: where there is a leap year in the Gregorian calendar (February is 29th), the leap surplus (aged more than a leap. The lunar calendar is less than the year of the return year).

2, Leap Year Judgment method: four Years a leap, A.D. year can be divisible by 4 can not be divisible by 100, or can be divisible by 400 years.

3, because recently learning JavaScript, so now use javascript+html to implement this function, the code is as follows:

Run as follows:

4, it is simple to verify the following table shows:

User input Expected results Actual output
2012 Leap Leap
2013 Not a leap year Not a leap year
2013abc Illegal input Illegal input
Abch Illegal input Illegal input

Test 1:

Test 2:

Test 3:

Test 4:

Code Gameover, I went to write parallel computing homework, TA sister goodbye ...

A leap year test program that detects whether the input is legitimate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.