Write a Java Program to Find Whether the Person is Eligible to Vote or Not

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.

person-eligible-to-vote-java-program-decoderp

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 : 22
Person is eligible to vote.

Output-2

Enter you age : 16
Person is not eligible to vote.

Post a Comment

0 Comments