First off, you need to get the user to enter the year as well as the month!
The simple solution is to use the built in classes:
DateTime startOfMonth = new DateTime(year, month, 1);
int daysInMonth = startOfMonth.AddMonths(1).AddDays(-1).Day;
But ... if you hand that in, you will probably get thrown off the course ... you could use it to check your code though!
Since this is your homework, I won't give you code you can hand in:
Read in teh month and year, and use
int.TryParse[
^] to convert them to integers.
Then just follow the rules: if it's not February, it's trivial: month to days is constant, so you could use a
switch
or an array of constant values to convert it.
If it is February, then follow the rules. To check if something is divisible, use the
modulus (or remainder) operator[
^] if the remainder of a /b is zero, then a is divisible by b.
Give it a try - see how far you can get!