Write a program to accept the name, gender and age of a person from the user and check and display whether he/she is eligible to vote or not. A person is eligible to vote only when he/she is 18 years or more. (for Bluej)
Sample Output:
Name: _________ gender: ______ age: _______ eligibility: _____
Answers
Answered by
2
Answer:
i won't help
Explanation:
Answered by
6
Program Códe :
import java.util.*;
class number
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter name");
String name = sc.nextInt();
System.out.println("Enter gender");
String gender = sc.nextInt();
System.out.println("Enter age");
int age = sc.nextInt();
if(age >= 18)
System.out.println("Eligible to vote");
else
System.out.println("Not eligible to vote");
}
}
Output :
If age < 18 :
Enter name
Riya Das
Enter gender
Female
Enter age
13
Not eligible to vote
If age > 18 :
Enter name
Sriya Das
Enter gender
Female
Enter age
45
Eligible to vote
For better understanding refer to the attachment.
Attachments:
Similar questions