Java Classic Programming question 50-way 14

Source: Internet
Author: User

Enter a certain day of the year, judging the day is the first of the year?

public class Example14 {
public static void Main (string[] args) {
Year (2017, 1, 1);
}

public static void year (int year, Int. month, int day) {
int d = 0;
int days = 0;
if (Year < 0 | | Month < 0 | | month > [|] Day < 0 | | Day > 31) {
SYSTEM.OUT.PRINTLN ("Input error, please re-enter!") ");
}
for (int i = 1; i < month; i++) {
switch (i) {
Case 1:
Case 3:
Case 5:
Case 7:
Case 8:
Case 10:
Case 12:
days = 31;
Break
Case 4:
Case 6:
Case 9:
Case 11:
days = 30;
Break
Case 2:
If ((year% 400 = = 0) | | (year% 4 = = 0 && Year% 100! = 0)) {
days = 29;
} else {
days = 28;
}
Break
}
D + = days;
}
SYSTEM.OUT.PRINTLN (Year + "years" + month + "Month" + Day + "date" + "
+ (d + day) + "days." ");
}
}

Java Classic Programming question 50-way 14

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.