A program that will input Word in month from (2000 January to December) and their Numeric dates and output how many week it consume and display whether it is Monday, Tuesday, Wednesday, and etc. Relate the program below:
SAMPLE OUTPUT
Enter Word Month : January
Enter Numeric Date : 31
January 31,2001 is equivalent to 31 days.
It is equivalent to 4 weeks and 3 days.
January 31,2001 is Monday.
Enter Word Month : Jry
Enter Numeric Date : 31
INVALID ENTRY!
Enter Word Month : December
Enter Numeric Date : 33
INVALID ENTRY!
NOTE: Please include from each program the INVALIDATION For instance 'INVALID ENTRY'!.
1
Expert's answer
2012-07-24T10:01:44-0400
class Program
{
private const int YEAR = 2000;
static void Main(string[] args)
{
Console.Write("Enter Word Month: ");
string monthInput = Console.ReadLine();
Console.Write("Enter Numveric Date: ");
string dateInput = Console.ReadLine();
DateTime dt;
//try parsing the combined input as a date
if (DateTime.TryParse(string.Format("{0} {1}, {2}", monthInput, dateInput, YEAR), out dt))
{
int days = DateTime.DaysInMonth(YEAR, dt.Month); // get days in the month
Console.WriteLine("{0:MMMM d,yyy} is equivalent to {1} days.", dt, days);
Console.WriteLine("It is equivalent to {0} weeks and {1} days.", days / 7, days % 7);
Console.WriteLine("{0:MMMM d,yyy} is {1}", dt, dt.DayOfWeek);
Comments
Leave a comment