Computer Science, asked by paulsaumya08, 4 months ago

write a java program if a person can vote or not
Hint- if age is greater or equal to 18 the person is eligible to vote ​

Answers

Answered by superkp2019
1

Answer:

import java.until.scanner

package election

Class age{

public static void main(String arcs[])

{

  Scanner scan=new Scanner (System.in);

  System.out.println(“Enter the age of person”);

  int user_age=scan.nextInt();

 System.out.println(“The age of person is”+user_age);

 if(user_age>18)

  {

   System.out.println(“You are eligible to Vote”);

  }

else

 {

   System.out.println(“You are not eligible to vote”);

   }

 }

}

Explanation:

Answered by jassi1178
2

Answer:

public class vote

{

public static void main(String[] args)

{

checkEligibility();

}

static void checkEligibility(){

int age;

Scanner sc=new Scanner(System.in);

System.out.print("What is your age?");

age=sc.nextInt();

if(age>=18)

System.out.println("You are eligible to vote.");

else

System.out.println("You are not eligible to vote.");

}

}

Thanks for A2A!

Similar questions