Q:

write c# program to read the number of week day from user, if it was between 1 to 5 then prints "work day", otherwise if it was between 6 to 7 then prints "weekend", solve it using switch statement

0

write c# program to read the number of week day from user,

if it was between 1 to 5 then prints "work day", otherwise if it was between 6 to 7 then prints "weekend", solve it using switch statement

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

internal class Program
{
    private static void Main(string[] args)
    {
        int weekday;
        Console.Write("enter a week day: ");
        weekday = Convert.ToInt32(Console.ReadLine());
        switch (weekday)
        {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                Console.WriteLine("workday");
                break;
            case 6:
            case 7:
                Console.WriteLine("weekend");
                break;
        }
    }
}

 

using if statement:

internal class Program
{
    private static void Main(string[] args)
    {
int weekday;
Console.WriteLine(" please enter the day number between 1 to 7 ?");
weekday = Convert.ToInt32(Console.ReadLine());
if (weekday >= 1 && weekday =< 5)
    Console.WriteLine("it is a workday");

else if (weekday == 6 || weekday == 7)
    Console.WriteLine("its a weekend");
else
    Console.WriteLine("wrong number");
}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now