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