write a program in java to find the age and find whether their age is eligible to vote or not using scanner class method ?
Answers
Answered by
2
import java.util.Scanner;
public class VotingAge
{
public static void main(String[] args)
{
int age;
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age=");
age = sc.nextInt();
if (age >= 18)
{
System.out.println("You are eligible for vote.");
}
else
{
System.out.println("You are not eligible for vote.");
}
}
}
- Output:
- Enter your age=19
- You are eligible for vote.
Similar questions
Science,
3 months ago
Math,
3 months ago
English,
7 months ago
Social Sciences,
11 months ago
Math,
11 months ago