4.28.FOR Loops and Exercises

Source: Internet
Author: User

if (m = = 1 | | m = = 3 | | m = = 5 | | m = = 7 | | m = = 8 | | m = = | | m = = 12)

{

if (d <= && d > 0)//date entered correctly

{

Console.WriteLine ("Date entered correctly!") ");

Console.WriteLine (Y + "year" + M + "month" + D + "Day");

}

Else

{

Console.WriteLine ("Date entered incorrectly!") ");

}

}

else if (m = = 4 | | m = = 6 | | m = 9 | | m = = 11)//input is Xiao Yue

{

if (d <= && d > 0)//date entered correctly

{

Console.WriteLine ("Date entered correctly!") ");

Console.WriteLine (Y + "year" + M + "month" + D + "Day");

}

Else

{

Console.WriteLine ("Date entered incorrectly!") ");

}

}

else if (m = = 2)//If it is February

{

Determine if a leap year

The year can be divisible by 4 and not divisible by 100

Special year: Or, the year can be divisible by 400

if (y% 4 = = 0 && y% = 0) | | y% 400 = 0)//description is currently a leap year

{

if (d <= && d > 0)//date correct

{

Console.WriteLine ("Date entered correctly!") ");

Console.WriteLine (Y + "year" + M + "month" + D + "Day");

Console.WriteLine (y + "years is a leap year!) ");

}

else//Date Error

{

Console.WriteLine ("Date entered incorrectly!") ");

}

}

else//description is not a leap year

{

if (d <= && d > 0)//date correct

{

Console.WriteLine ("Date entered correctly!") ");

Console.WriteLine (Y + "year" + M + "month" + D + "Day");

Console.WriteLine (y + "years is not a leap year!) ");

}

else//Date Error

{

Console.WriteLine ("Date entered incorrectly!") ");

}

}

}

}

Else//Month Error

{

Console.WriteLine ("Incorrect month input!) ");

}

}

else//Year input error

{

Console.WriteLine ("The year entered incorrectly!") ");

}

Console.ReadLine ();

}

}

}

4.28.FOR Loops and Exercises

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.