here... solve this program.... it's urgent
Answers
Answer:
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");
}
}
}
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 .
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");
}
}
}
( pls pls pls mark me a brainliest )