Computer Science, asked by agriya, 1 year ago

write an program to check person is eligibility to vote​

Answers

Answered by SahilNarang
30
import java.util.Scanner
class Eligibility
{
public static void main (String args[])
{
Scanner a = new Scanner (System.in)
int age;
age = a.nextInt();
if (age<=18)
{
System.out.println("Eligible");
}
else
{
System.out.println("Not Eligible");
}
}
}


agriya: java
Answered by StaceeLichtenstein
7

Program to check the person is eligibility to vote is given below​

Explanation:

Following are the program in C++ language

#include <iostream>  // header file

using namespace std; //  namespace

int main() // main function

{

   int x1; // variable declaration

   cout<< "Enter the age of person:";

   cin>>x1; // Read the age

   if(x1>=18) // check condition

   {

       cout<<"person is eligible for vote"; // display

   }

   else

   {

               cout<<"person is not eligible for vote"; // display

   }

   return 0;

}

Output:

Enter the age of person:19

person is eligible for vote

Following are the description of program

  • Declared a variable "x1" of int type .
  • Read the value of "x1" by user by using cin statement
  • Check the condition of if block .If block condition is true then it executed the statement inside the if block otherwise else block will be executed .

Learn More:

  • brainly.in/question/8474848
Similar questions