Java program to find a person is eligible to vote or not using if else to check person is eligibility 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”);
into 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”);
}
}
}
Answer:
package stringpractice;
public class StringPractice {
public static void main(String[] args) {
int age=5;
if(age>18)
{
System.out.println("Eligible to vote");
}
else
{
System.out.println("Not eligible to vote");
}
}
}
Explanation:(Without using scanner class)