1.Write a program to enter a number from 1 to 7 and display the corresponding day of the week.
Hint: 1 = Monday
(Duration: 30 min)
ANSWER:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
l:
Console.WriteLine("1.Sunday\n2.Monday\n3.Tuesday\n4.Wednesday\n5.Thesday\n6.Friday\n7.Satureday");
Console.WriteLine("Enter your choise:");
int ch = Convert.ToInt32(Console.ReadLine());
switch (ch)
{
case 1:
{
Console.WriteLine("Sunday");
break;
}
case 2:
{
Console.WriteLine("Monday");
break;
}
case 3:
{
Console.WriteLine("Tuesday");
break;
}
case 4:
{
Console.WriteLine("Wednesday");
break;
}
case 5:
{
Console.WriteLine("Thesday");
break;
}
case 6:
{
Console.WriteLine("Friday");
break;
}
case 7:
{
Console.WriteLine("Satureday");
break;
}
default:
{
Console.WriteLine("Invalid option");
break;
}
}
Console.WriteLine("Do u wan to contineu?");
char op = Convert.ToChar(Console.ReadLine());
if (op == 'y' || op == 'Y')
{
goto l;
}
else
{
goto e;
}
e:
Console.ReadLine();
}
}
}
Hint: 1 = Monday
(Duration: 30 min)
ANSWER:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
l:
Console.WriteLine("1.Sunday\n2.Monday\n3.Tuesday\n4.Wednesday\n5.Thesday\n6.Friday\n7.Satureday");
Console.WriteLine("Enter your choise:");
int ch = Convert.ToInt32(Console.ReadLine());
switch (ch)
{
case 1:
{
Console.WriteLine("Sunday");
break;
}
case 2:
{
Console.WriteLine("Monday");
break;
}
case 3:
{
Console.WriteLine("Tuesday");
break;
}
case 4:
{
Console.WriteLine("Wednesday");
break;
}
case 5:
{
Console.WriteLine("Thesday");
break;
}
case 6:
{
Console.WriteLine("Friday");
break;
}
case 7:
{
Console.WriteLine("Satureday");
break;
}
default:
{
Console.WriteLine("Invalid option");
break;
}
}
Console.WriteLine("Do u wan to contineu?");
char op = Convert.ToChar(Console.ReadLine());
if (op == 'y' || op == 'Y')
{
goto l;
}
else
{
goto e;
}
e:
Console.ReadLine();
}
}
}
No comments:
Post a Comment