Q:

Write C# Program to detrermine a candidate’s age is eligible for casting the vote or not.

0

Write C# Program to detrermine a candidate’s age is eligible for casting the vote or not.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
 
public class charpexercise
{
    static void Main(string[] args)
    {
 
        int Candiateage;
 
        Console.WriteLine("Input the age of the candidate : ");        
        Candiateage = Convert.ToInt32(Console.ReadLine());
 
        if (Candiateage < 18)
        {
            Console.WriteLine("Sorry, You are not eligible to caste your vote.\n");
            Console.WriteLine(18 - Candiateage + "You would be able to caste your vote after %d year.\n");
        }
 
        else
        {
            Console.WriteLine("Congratulation! You are eligible for casting your vote.\n");
        }        
 
        Console.ReadLine();
    }
}

Result:

Input the age of the candidate : 

19

Congratulation! You are eligible for casting your vote.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C# Program to find the eligibility for an en... >>
<< Write C# Program to accept two integers and check ...