Answer to Question #122685 in C# for em'ma

Question #122685
Task 5: Calculate number of days since the Independence Day

Write a function num_indep_days() which computes the number of days elapsed since 14th August 1947 to the date provided as input to the function. Remember that February of each leap year has 29 days! The function prototype is given below:

int num_indep_days(int day, int month, int year)
1
Expert's answer
2020-06-17T03:01:24-0400
class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter the year: ");
            int year = int.Parse(Console.ReadLine());


            Console.Write("Enter the month(number): ");
            int month = int.Parse(Console.ReadLine());


            Console.Write("Enter the day: ");
            int day = int.Parse(Console.ReadLine());




            Console.WriteLine($"The number of days elapsed since 14th August 1947 to the provided date is  {num_indep_days(day, month, year)}");


            Console.Write("Press any key to close app...");
            Console.ReadKey();
        }


        public static int num_indep_days(int day, int month, int year)
        {
            DateTime date = new DateTime(1947, 08, 14),
                providedDate = new DateTime(year, month, day);


            return (int)Math.Floor((providedDate - date).TotalDays);
        }
    }

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

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS