Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework3
- {
- class Program
- {
- public static void Main(string[] args)
- {
- Console.WriteLine("Enter EGN");
- string egn = Console.ReadLine();
- char[] arrEgn = egn.ToCharArray();
- int year = int.Parse(String.Concat(arrEgn[0], arrEgn[1]));
- int month = int.Parse(String.Concat(arrEgn[2], arrEgn[3]));
- int day = int.Parse(String.Concat(arrEgn[4], arrEgn[5]));
- String control = arrEgn[9].ToString();
- DateTime now = DateTime.Today;
- if (month >= 41)
- {
- year += 2000;
- month -= 40;
- }
- else if (month >= 21)
- {
- year += 1800;
- month -= 20;
- }
- else
- {
- year += 1900;
- }
- DateTime birthday = new DateTime(year, month, day);
- var totalDays = (now - birthday).TotalDays;
- var totalYears = Math.Truncate(totalDays / 365);
- var totalMonths = Math.Truncate((totalDays % 365) / 30);
- var remainingDays = Math.Truncate((totalDays % 365) % 30);
- Console.WriteLine("{0} years, {1} months, {2} days, control number: {3}", totalYears, totalMonths, remainingDays, control);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement