Showing posts with label legal age in c#. Show all posts
Showing posts with label legal age in c#. Show all posts

Friday, October 20, 2017

Legal Age Checker in C#

I wrote this simple program in C# as an example for my upcoming book on C# programming what does the program will do is to check if the given age of the user is already an adult or not. The code is very easy to understand and use I hope you will find my work useful.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.



Sample Program Output


Program Listing

age.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace legal_age
{
    class legal_age
    {
        static void Main(string[] args)
        {
            string reply;
            int n = 0;
            int age = 0;
          
            do
            {
                Console.Clear();
                Console.Write("Legal Age Checker ");
                Console.Write("\n\n");
                Console.Write("Enter Your Age    : ");
                age = Convert.ToInt32(Console.ReadLine());

                if (age >= 18)
                {
                    Console.Write("\n\n");
                    Console.WriteLine("At the age {0} you are already an Adult.",age);
                }
                else
                {
                    Console.Write("\n\n");
                    Console.WriteLine("At the age {0} you are still a Minor.",age);
                }
                Console.Write("\n\n");
                Console.Write("Do You Want To Continue? Y/N : ");
                reply = Console.ReadLine();

                if (reply == "y" || reply == "Y")
                {
                    continue;
                }
                else if (reply == "n" || reply == "N")
                {
                    Console.Write("\n\n");
                    Console.Write("Thank You For Using This Software.");
                    Console.Write("\n\n");
                    break;
                }

            } while (n == 0);
            Console.ReadLine();
        }
    }
}