Java program to check eligibility for voting using if else

In this program we are going to check eligibility for voting using if else by taking user input age. 


//Voting elegibility program
import java.util.Scanner;
class IfElse5{
public static void main(String args[]){

int a;
int b=18;

Scanner c=new Scanner(System.in);

System.out.println("please enter your age");

a=c.nextInt();

if(a>=b) {
System.out.println("congratulation you are eligible for voting");
    }

else{
 System.out.println("Sorry you are not eligible for voting");
   }

 }
}



No comments:

Post a Comment