Write a c# program named CheckMonth2 that prompts a user to enter a birth month and day. Display an error message that says Invalid date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day entered is 17, the output should be 2/17 is a valid birthday.
using System;
class CheckMonth2
{
static void Main()
{
int dd,mm; //declare dd to store day and mm to store month
//declare and initialize an array to assign the values of the dates
of every month
int [] day = new int[12]
{31,29,31,30,31,30,31,31,30,31,30,31};
//ask user to input the month
Console.WriteLine("Enter the month(1 to 12)");
//read the value of month from user and assign it to mm by using
the concepts of type casting
mm=Convert.ToInt32(Console.ReadLine());
//ask user to input the day
Console.WriteLine("Enter the day");
//read the value of day from user and assign it to dd by using the
concepts of type casting
dd=Convert.ToInt32(Console.ReadLine());
//condition to check the validity of month and day
if((mm>=1 && mm<=12) && (dd >=1 &&
dd<=day[mm-1]))
{ //write the valid message
Console.WriteLine("{0}/{1} is a Valid Birthday",mm,dd);
}
else
//write the invalid message
Console.WriteLine("Invalid date");
}
}
OUTPUT



Write a c# program named CheckMonth2 that prompts a user to enter a birth month and...