Java Program To Allow User To Enter The Age And Check User’s Vote Eligibility – For Beginners

Java

Video is ready, Click Here to View ×


Code :

import java.util.*;
public class Age
{
public static void main(String args[])
{
//User will enter the age and the program will check he/she is eligible to vote or not..
Scanner sc = new Scanner(System.in);
int age = 0; //initial variables must be declared and initialized by zero in java..
System.out.print(“Enter the age :”);
age = sc.nextInt();
if(age &gt= 18)
{
System.out.println(“The User is Eligible To Vote.”);
}
else
{

1 thought on “Java Program To Allow User To Enter The Age And Check User’s Vote Eligibility – For Beginners

Leave a Reply

Your email address will not be published. Required fields are marked *