Answer to Question #251187 in C# for Holik

Question #251187
Create a program to output the day of the week according to the number entered on the keyboard.
1
Expert's answer
2021-10-14T16:04:59-0400
using System;
using System.Collections.Generic;


namespace Questions
{
    class Program
    {
        
        static void Main()
        {
            List<string> days = new List<string>() 
                { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };


            Console.Write("Enter a number (1-7): ");
            int day = int.Parse(Console.ReadLine());


            if (day >= 1 && day <= 7)
                Console.WriteLine("Day of week: " + days[day - 1]);
            else
                Console.WriteLine("Invalid number");




            Console.WriteLine();
            Console.ReadKey();
        }
    }


}

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
APPROVED BY CLIENTS