I am going to write a program that will tell the user the number of days in a individual month. The program should allow the user to enter a whole number representing the month (Jan = 1, Feb = 2, etc.). After checking that this is a valid month number (i.e., between 1 and 12), program should then determine the number of days in that month two different times: once using a series of if statements and once using a switch statement.
Place the resulting number of days in two different output Labels.
NOTE: Assume that February always has 28 days.
[EDIT]
private void button1_Click(object sender, EventArgs e)
{
int monthNo = 0;
string[] month = new string[13];
month[0] = "\0";
month[1] = "January"; month[2] = "February"; month[3] = "March";
month[4] = "April"; month[5] = "May"; month[6] = "June";
month[7] = "July"; month[8] = "August"; month[9] = "September";
month[10] = "October"; month[11] = "November"; month[12] = "December";
{
monthNo = int.Parse(monthNoText.Text);
if (monthNo <= 0 || monthNo > 12)
{
MessageBox.Show("Invalid Input!!",
"Must be 1 to 12!!");
}
{
switch (monthNo)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
switchText.Text = "31 days";
break;
case 4:
case 6:
case 9:
case 11:
switchText.Text = "30 days";
break;
case 2:
switchText.Text = "28 days";
break;
}
this is what i got but i need the same info in stch label and if label