5 (30%) Date practical applications In practice we usually need to plan events q
ID: 3604900 • Letter: 5
Question
5 (30%) Date practical applications In practice we usually need to plan events quite a few days from now (today), and we need to know one how many days the day of event is from today and two: also which day of the week is the day of event (a) write a C# program that asks you to input a first date, ie, the starting date with the day of the week such as November 1, 2017, Wednesday, or (11, 1, 2017, 3) where 11 means the 11 month or November, and 3 after 2017 means the 3d day of the week or Wednesday (Sunday can be 7 or 0) This Cl program then will ask a second date, ending date, or the date of event such as (3, 21, 2018). (b) Your program will calculate 1: the number of days from 11/1/17 exclusive to 3/21/18 inclusive, which is 140 days, and 2: which day of the week march 21, 2018 is, which is also wednesday k since . 140%7-0). (c) Test your program with at least 3 pairs of test dates: DI:starting date: today, ending date, Thanksgiving of 2017; D2: starting date New yeat of 2017, ending date: Memorial day of 2017, D3: dates of your choice, at least 200 days apartExplanation / Answer
I have written the C# program for days difference and finding the week date of the event ending date, please find the code below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace DaysCalculation
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter a starting date of month: ");
int month = int.Parse(Console.ReadLine());
Console.Write("Enter a starting date of day: ");
int day = int.Parse(Console.ReadLine());
Console.Write("Enter a starting date of year: ");
int year = int.Parse(Console.ReadLine());
DateTime oldDate = new DateTime(year,month, day);
Console.Write("Enter a ending date of month: ");
int secmonth = int.Parse(Console.ReadLine());
Console.Write("Enter a ending date of day: ");
int secday = int.Parse(Console.ReadLine());
Console.Write("Enter a ending date of year: ");
int secyear = int.Parse(Console.ReadLine());
DateTime newDate = new DateTime(secyear, secmonth, secday);
Console.WriteLine("Second ending date is : " + newDate.DayOfWeek);
// Difference in days, hours, and minutes.
TimeSpan ts = newDate - oldDate;
// Difference in days.
int differenceInDays = ts.Days;
Console.WriteLine("Difference Between Days : " + differenceInDays);
Console.ReadKey();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.