Advertisement
EvenGuy

BirthDay in C#

Dec 7th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication21
  8. {
  9.     class BirthDay
  10.     {
  11.         private DateTime BDay;
  12.  
  13.         // Получение дня рождения
  14.         public void GetBDay()
  15.         {
  16.             Console.Write("Введите свой день рождения: ");
  17.             BDay = Convert.ToDateTime(Console.ReadLine());
  18.         }
  19.  
  20.         // Получение возраста
  21.         public int ReturnAge()
  22.         {
  23.             return DateTime.Today.Year - BDay.Year;
  24.         }
  25.  
  26.         // Получение кол-ва месяцев до дня рождения
  27.         public int ReturnMonthToBDay()
  28.         {
  29.             if (DateTime.Today.Month < BDay.Month)
  30.                 return BDay.Month - DateTime.Today.Month;
  31.             else
  32.                 return 12 - DateTime.Today.Month + BDay.Month;
  33.         }
  34.  
  35.         // Поулчение кол-ва дней до ДР
  36.         public int ReturnDaysToBDay()
  37.         {
  38.             int Days;
  39.  
  40.             if (DateTime.Today.Month <= BDay.Month)
  41.             {
  42.                
  43.             }
  44.  
  45.                
  46.  
  47.         }
  48.     }
  49.  
  50.     class Program
  51.     {
  52.         static void Main(string[] args)
  53.         {
  54.             BirthDay BDay = new BirthDay();
  55.  
  56.             BDay.GetBDay();
  57.             Console.WriteLine("Сейчас вам "+BDay.ReturnAge()+" лет. Ваш день рождения через "+BDay.ReturnMonthsToBDay()+" месяцев.");
  58.             Console.ReadLine();
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement