Computer Science, asked by tarun6450, 9 months ago

Lab Questions
write a Java program that prompts the user to enter the age of a person and then prints whether
that person is eligible to vote or not. Create this program using the if-else construct. (Hint: A
person whose age is equal to or above 18 years is eligible to vote.)

Answers

Answered by dawar78
4

import java.util.Scanner;

class Age

{

int age;

public static void main (String args[ ])

{

Scanner sc=new Scanner (System.in);

System.out.println("Enter your age");

age=sc.nextInt();

if (age>=18){

System.out.println("eligible");

}

else{

System.out.println("not eligible");

}

}

}

Similar questions