Computer Science, asked by sanjana1215, 7 months ago

write a program in java to find the age and find whether their age is eligible to vote or not using scanner class method ?​

Answers

Answered by derenamanjha1234
2

import java.util.Scanner;

public class VotingAge

{

   public static void main(String[] args)

   {

       int age;

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter your age=");

       age = sc.nextInt();

       if (age >= 18)

       {

           System.out.println("You are eligible for vote.");

       }

       else

       {

           System.out.println("You are not eligible for vote.");

       }

   }

}

  • Output:
  • Enter your age=19
  • You are eligible for vote.

Similar questions