Answer to Question #343904 in C# for Bibo

Question #343904

Create an enumeration named month that hold the values for the months of the year. Starting with January equal to 1.write a program that prompts the user a month's integers convert user's entry to a month's values,and display it

1
Expert's answer
2022-05-23T15:17:31-0400
using System;
namespace ConsoleApp1
{
  class Program
  {
    public enum Month
    {
      January = 1,
      February,
      March,
      April,
      May,
      June,
      July,
      August,
      September,
      October,
      November,
      December
    }
    static void Main(string[] args)
    {
      string str = "";
      int Number;
      while (str != "Exit" && str != "E" && str != "exit" && str != "e")
      {
        Console.Write("Write a number from 1 to 12 (Or write the Exit): ");
        str = Console.ReadLine();
        if (int.TryParse(str, out Number))
          if (Number >= 1 && Number <= 12)
            Console.WriteLine((Month)Number);
      }
    }
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS