Conditional Statement Practice

Source: Internet
Author: User

Enter Month day, check all kinds, check whether correct
* Year Range 0~9999
* Month Range 1~12
* Scope of the day:
* (1) 31 Days of the month
* (2) 30 days of the month
* The number of people in February of the average year
* (4) Number of February leap years
* If the entered year format is correct, print "* * * * * month * day"


Console.Write ("Enter year:");
int a = Int. Parse (Console.ReadLine ());
Console.Write ("Enter month:");
int b = Int. Parse (Console.ReadLine ());
Console.Write ("Enter Date:");
int c = Int. Parse (Console.ReadLine ());
if (a > 0 && a <= 9999)
{
If (a% 4! = 0)
{
if (b = = 1 | | b = = 3 | | b = = 5 | | b = = 7 | | b = 8 | | b = | | | b = 12)
{
if (C > 0 && C <= 31)
{
Console.WriteLine (A + "year" + B + "month" + C + "Day");
}
Else
{
Console.WriteLine ("Incorrect date input");
}
}
else if (b = = 4 | | b = = 6 | | b = = 9 | | b = = 11)
{
if (C > 0 && C <= 30)
{
Console.WriteLine (A + "year" + B + "month" + C + "Day");
}
Else
{
Console.WriteLine ("Incorrect date input");
}
}
Else
{
if (b = = 2)
{
if (C > 0 && C <= 28)
{
Console.WriteLine (A + "year" + B + "month" + C + "Day");
}
Else
{
Console.WriteLine ("Incorrect date input");
}
}
Else
{
Console.WriteLine ("Incorrect month input");
}
}
}
Else
{
If (a% 400 = = 0 | | (a% 4 = = 0 && A% 100! = 0))
{
if (b = = 1 | | b = = 3 | | b = = 5 | | b = = 7 | | b = 8 | | b = | | | b = 12)
{
if (C > 0 && C <= 31)
{
Console.WriteLine (A + "year" + B + "month" + C + "Day");
}
Else
{
Console.WriteLine ("Incorrect date input");
}
}
else if (b = = 4 | | b = = 6 | | b = = 9 | | b = = 11)
{
if (C > 0 && C <= 30)
{
Console.WriteLine (A + "year" + B + "month" + C + "Day");
}
Else
{
Console.WriteLine ("Incorrect date input");
}
}
Else
{
if (b = = 2)
{
if (C > 0 && C <= 29)
{
Console.WriteLine (A + "year" + B + "month" + C + "Day");
}
Else
{
Console.WriteLine ("Incorrect date input");
}
}
Else
{
Console.WriteLine ("Incorrect month input");
}
}
}
}
}
Else
{
Console.WriteLine ("Incorrect year input");
}
Console.ReadLine (); */

Conditional Statement Practice

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.