65 721
Assignments Done
99,2%
Successfully Done
In October 2018

Answer to Question #12074 in C# for Cherry blossom

Question #12074
it is known that november 1993 starts on monady.help me 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 answered for day, the program must display 'WEDNESDAY';if 8 was entered,'MONDAY' must be displayed and so on.
I have made my own program then turns out to have many errors.. i just wanna compare your answer and mine :) thank you!
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