Program to check candidate is eligible or not for vote using function in java.

import java.util.*;
public class function {
    public static boolean checkAge(int n){
        if(n>18)
        return true;
        else
        return false;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("enter the age =");
        int n=sc.nextInt();
        System.out.print(checkAge(n));
    }
}
■》output->

enter the age =17

false

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.