68 249
Assignments Done
99%
Successfully Done
In November 2018

Answer to Question #11973 in C# for cherry

Question #11973

It is known that November 1993 starts on a Monday. Make a program that would input a numeric day(between 1 and 30) and output the day of the week the day falls. For example, if 3 is entered for day, the program must display "WEDNESDAY", if 8 was entered,"MONDAY" must be displayed and so on...
Expert's answer
using System;
using System.Collections.Generic;
using
System.Linq;
using System.Text;

namespace
ConsoleApplication1
{
class Program
{
static void
Main(string[] args)
{
int NumericDay;

ConsoleKeyInfo KeyInfo;
do{

do{
Console.WriteLine ("Input a numeric day(between 1 and
30):");
while(! int.TryParse (Console.ReadLine(), out
NumericDay))
{
Console.WriteLine
("Input a numeric day(between 1 and 30):");

}
if ((NumericDay < 1) || (NumericDay >
30))
{
Console.WriteLine ("ERROR! A
numeric day must be between 1 and 30!");
}

else break;

} while(true);


NumericDay = NumericDay % 7;

switch
(NumericDay)
{
case
0:

Console.WriteLine("SUNDAY");

break;
case 1:

Console.WriteLine("MONDAY");

break;
case 2:

Console.WriteLine("TUESDAY");

break;
case 3:

Console.WriteLine("WEDNESDAY");

break;
case 4:

Console.WriteLine("THURSDAY");

break;
case 5:

Console.WriteLine("FRIDAY");

break;
case 6:

Console.WriteLine("SATURDAY");

break;
default: break;

}
Console.WriteLine ("Press any key to continue OR Escape to
Quit");
KeyInfo = Console.ReadKey ();
}
while(KeyInfo.Key != ConsoleKey.Escape);
}
}
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions