Khoi

Khoi

  • NA
  • 18
  • 0

Input month - Get days

Nov 5 2009 11:16 AM
I'd like to code a program which user can input a month, then the program shows a number of days. Below is my code, but it shows an error " Class, struct, or interface method must have a return type". Please advise


 class GetDays
    {

        string Month = 0;
        public GetNumOfDay()
        {
            switch (Month)
            {
                case January: case March: case May: case July: case December:
                    Console.WriteLine("This month has 31 days {0}",Month);
                    break;

                case April: case June: case September: case November:
                    Console.WriteLine("This month has 30 days {0}", Month);
                    break;

                case Febuary:
                    if (Month / 400 != 0)
                    {
                        Console.WriteLine("This month has 28 days {0}", Month);
                    }
                    else Console.WriteLine("This  month has 29 days {0}", Month);
                default:
                    Console.WriteLine("Invalid month");
            }
        }
 
    }
    class Program
    {
        static void Main(string[] args)
        {
            GetDays obj = new GetDays();
            obj.GetNumOfDay();
            Console.ReadLine();
        }
    }

Answers (4)