Real World Example

Loan Eligibility Check

Lending apps decide in milliseconds whether you are eligible for a loan. Under the hood it is a set of boolean rules.

Example

public class Main {
    public static void main(String[] args) {
        int age = 29;
        double monthlyIncome = 45000;
        int creditScore = 742;
        boolean hasExistingDefault = false;
        boolean panVerified = true;

        boolean ageOk = age >= 21 && age <= 60;
        boolean incomeOk = monthlyIncome >= 25000;
        boolean scoreOk = creditScore >= 700;
        boolean eligible = ageOk && incomeOk && scoreOk && !hasExistingDefault && panVerified;

        System.out.println("Age OK      : " + ageOk);
        System.out.println("Income OK   : " + incomeOk);
        System.out.println("Score OK    : " + scoreOk);
        System.out.println("No defaults : " + !hasExistingDefault);
        System.out.println("PAN verified: " + panVerified);
        System.out.println("ELIGIBLE    : " + eligible);
    }
}

Output

Age OK      : true
Income OK   : true
Score OK    : true
No defaults : true
PAN verified: true
ELIGIBLE    : true