write a java program if a person can vote or not
Hint- if age is greater or equal to 18 the person is eligible to vote
Answers
Answer:
import java.until.scanner
package election
Class age{
public static void main(String arcs[])
{
Scanner scan=new Scanner (System.in);
System.out.println(“Enter the age of person”);
int user_age=scan.nextInt();
System.out.println(“The age of person is”+user_age);
if(user_age>18)
{
System.out.println(“You are eligible to Vote”);
}
else
{
System.out.println(“You are not eligible to vote”);
}
}
}
Explanation:
Answer:
public class vote
{
public static void main(String[] args)
{
checkEligibility();
}
static void checkEligibility(){
int age;
Scanner sc=new Scanner(System.in);
System.out.print("What is your age?");
age=sc.nextInt();
if(age>=18)
System.out.println("You are eligible to vote.");
else
System.out.println("You are not eligible to vote.");
}
}
Thanks for A2A!