View difference between Paste ID: apT8ARA4 and FWg2m8Jv
SHOW: | | - or go back to the newest paste.
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
7-
    class Program
7+
class AgeAfterTenYears
8
{
9-
        static void Main(string[] args)
9+
    static void Main(string[] args)
10
    {
11-
            Console.Write("Enter your birthday: ");
11+
        Console.Write("Enter your birthday: ");
12-
            string birsthdayStr = Console.ReadLine();
12+
        string birsthdayStr = Console.ReadLine();
13-
            DateTime birthday;
13+
        DateTime birthday;
14-
            int currentYear = DateTime.Now.Year;
14+
        int currentYear = DateTime.Now.Year;
15-
            int yearOfBirth;
15+
        int yearOfBirth;
16-
            int ageNow;
16+
        int ageNow;
17-
            int ageAfterTenYears;
17+
        int ageAfterTenYears;
18-
            bool birthdayCorrectFormat = DateTime.TryParse(birsthdayStr, out birthday);
18+
        bool birthdayCorrectFormat = DateTime.TryParse(birsthdayStr, out birthday);
19-
            if (birthdayCorrectFormat)
19+
        if (birthdayCorrectFormat)
20
        {
21-
                yearOfBirth = birthday.Year;
21+
            yearOfBirth = birthday.Year;
22
            DateTime birthdayThisYeas = new DateTime(currentYear, birthday.Month, birthday.Day);
23-
                ageAfterTenYears = ageNow + 10;
23+
            if (birthdayThisYeas > DateTime.Today)
24-
                Console.WriteLine("Your age after 10 years: {0}", ageAfterTenYears);
24+
25
                ageNow = (currentYear - yearOfBirth) - 1;
26
            }
27
            else
28-
                Console.WriteLine("Wrong format of birthday.");
28+
29
                ageNow = currentYear - yearOfBirth;
30
            }
31-
    }
31+
            ageAfterTenYears = ageNow + 10;
32
            Console.WriteLine("Your age now: {0}. Your age after 10 years: {1}", ageNow, ageAfterTenYears);
33
        }
34
        else
35
        {
36
            Console.WriteLine("Wrong format of birthday.");
37
        }
38
    }
39
}