Java technology supports computing tools for several days and determining whether a leap year is used

Source: Internet
Author: User

[Java]
/*
* Start the program header annotation.
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: a tool that calculates the number of days in a month and determines whether it is a leap year.
* Author: Xue Guangchen
* Completion date: January 1, September 15, 2011
* Version No.: x1.0

* Description of tasks and Solutions
* Input description:
* Problem description:
* Program output:
* End the comment in the program Header
*/
 
Package xue.com;
 
Public class Calculate_Day {

Public static boolean judge (int year)
{
Boolean yearleap = (year % 400 = 0) | (year % 4 = 0) & (year % 100! = 0); // use boolean data computing to determine whether division can be performed
Return yearleap;
}

Public static int calculate (int year, int month)
{
Boolean yearleap = judge (year );
Int day;
If (yearleap & month = 2)
{
Day = 29;
}
Else if (! Yearleap & month = 2)
{
Day = 28;
}
Else if (month = 4 | month = 6 | month = 9 | month = 11)
{
Day = 30;
}
Else
{
Day = 31;
}
Return day;
}
}

Related Article

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.