write a java program that prompts the user to enter the age of a person and print weather that person i s eligible to vote or not. create this program using if-else construct.
Answers
Answered by
5
Answer:
import java.util.Scanner;
public class ProgramToShoEligibility {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your age in numbers : ");
int age = sc.nextInt();
if(age<16&&age>0){
System.out.println("You are not eligible to vote");
}else if(age>=16){
System.out.println("You can vote!");
}else {
System.out.println("You entered invalid age");
}
}
}
Explanation:
Similar questions