In India voting eligible age is 18 years old. This java program the user check who is upto eligible to vote or not. The user enter your age and press enter, Then program check and show result, eligible to vote or not.
In this java program use condition statement to find the result. It means if else statement, First check user input age is greater then 18 or not, If condition is true then show Person is eligible to vote, otherwise condition is false then show Person is not eligible to vote.
Java code
import java.util.Scanner
class Eligibility
{
public static void main (String args[])
{
Scanner sc = new Scanner (System.in)
int age;
System.out.println("Enter you age : ");
age = sc.nextInt();
if(age>=18)
{
System.out.println("Person is eligible to vote.");
}
else
{
System.out.println("Person is not eligible to vote.");
}
}
}
Output-1
Enter you age : 22Person is eligible to vote.
Output-2
Enter you age : 16Person is not eligible to vote.
0 Comments