Advertisement
milen8204

Problem 15 Homelork Introdusing to programming

Mar 10th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2. /* Write a program to read your birthday from the console
  3.  * and print how old you are now and how old you will be after 10 years. */
  4. class MyAgeAfter10Years
  5. {
  6.     static void Main()
  7.     {
  8.         Console.WriteLine("Enter your birth date:");
  9.         DateTime birthDate;
  10.         DateTime currentDate = DateTime.Now;
  11.        
  12.         if (DateTime.TryParse(Console.ReadLine(), out birthDate))
  13.         {
  14.             Console.WriteLine("You are {0} years old, after 10 years you will be {1} years old.", (currentDate.Year - birthDate.Year), (currentDate.Year - birthDate.Year + 10));
  15.         }
  16.         else
  17.         {
  18.             Console.WriteLine("You have entered not a valid birth date!");
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement