Computer Science, asked by nandinichaudhary1912, 16 days ago

Write a Java program to accept name and age from the user. If age is greater than or equal to 18 then display you can vote or else display you cannot vote. It should display it with user name.
IN JAVA ONLY!

Answers

Answered by aryankhaneja7
0

Answer:

public class Main

{

public static void main(String[] args) {

int age;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the year you want to check : ");

age = sc.nextInt();

//check voting eligibility

if (age>=18)

{

System.out.println("person is eligible for voting");

}

else

{

System.out.println("person is not eligibal for voting\n");

}

}

}

Explanation:

Similar questions