Advertisement
AnitaN

01.Intro-Programming-Homework/15.1.Date-After-10-Years

Mar 9th, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. //Problem 15.* Age after 10 Years
  2. //Write a program to read your birthday from the console and print how old you are now and how old you will be after 10 years.
  3.  
  4. using System;
  5.  
  6. class AgeAfter10Years
  7. {
  8.     static void Main()
  9.     {
  10.         Console.WriteLine("Please, enter your born year:");
  11.         int bornYear = int.Parse(Console.ReadLine());
  12.         int currentYear = DateTime.Now.Year;
  13.         //Your Age Now
  14.         int nowAge = currentYear - bornYear;
  15.         //Your Age after 10 years
  16.         int afterAge = nowAge + 10;
  17.         //Print to Console your age now and after 10 years
  18.         Console.WriteLine("Your age now is {0} and after 10 years you will be on {1} years.", nowAge, afterAge);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement