using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LeapYearForm
{
public partial class LeapYear : Form
{
public LeapYear()
{
InitializeComponent();
}
static bool isLeapYear(int checkYear)
{
int year = checkYear;
bool is_a_leap_year;
if ((year % 4) == 0)
{
if ((year % 100) == 0)
{
if ((year % 400) == 0)
// leap year
is_a_leap_year = true;
else
// not leap year
is_a_leap_year = false;
}
else
{
// leap year
is_a_leap_year = true;
} // end if
}
else
{
// not a leap year
is_a_leap_year = false;
} // end if
return is_a_leap_year;
}
private void determineLeapYear(object sender, EventArgs e)
{
bool isLeap = isLeapYear(Convert.ToInt32(inputYear.Text));
result.Visible = true;
if (isLeap)
result.Text = "This is a leap year";
else
result.Text = "This is not a leap year";
}
}
}
[/code]