Advertisement
cortez

Ten Years From Now

Oct 5th, 2012
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 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.     class TenYearsFromNow
  8.     {
  9.         static void Main()
  10.         {
  11.             Console.WriteLine("Please enter your birth year below...");
  12.  
  13.             int startingYear = 1900;
  14.             int nowadays = DateTime.Now.Year;
  15.             int birthYear = int.Parse(Console.ReadLine());
  16.             int currentAge = (nowadays - birthYear);//Calculates the current age.
  17.             int inTenYears = currentAge + 10;// Calculates the age ten years from now.
  18.  
  19.             //Let's check if the year people enter is correct.
  20.             if (birthYear >= startingYear && birthYear < nowadays)
  21.             {
  22.                 //Let's print out the current age:
  23.                 Console.WriteLine("You are now " + currentAge + " Years Old");
  24.  
  25.                 //Let's print out the age 10 years from now:
  26.                 Console.WriteLine("10 Years from now you will be: " + inTenYears + " Years Old");
  27.             }
  28.             else
  29.             {
  30.                 Console.WriteLine("Sorry pal!!! You either entered a wrong Birth Year or you're too old to look in the next 10 years :) !!!");
  31.             }
  32.             Console.WriteLine();
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement