bluej Programs
6.Write a program to enter the age of a person. Check whether he or she is eligible to vote or not.
import java.util.*;
class vote
{
void main()
{
Scanner sc=new Scanner(System.in);
int age;
System.out.println("Enter Your age:");
age=sc.nextInt();
if(age>=18)
System.out.println("Eligible to vote");
else
System.out.println("Not eligible to vote");
}
}
Output:
Enter Your age: 23 Eligible to vote
ADVERTISEMENT
