Boolean Logic Evaluator (Java Assignment)

This program practices boolean expressions and decision-making using &&, ||, and ! with nested conditions and short-circuit logic.

Java Boolean Logic if / else Input Validation Short-circuit

Specification Sheet

Program Name
Boolean Logic Evaluator
Goal
Use boolean logic to evaluate loan eligibility
Output
Eligible? (true/false) + detailed explanation

Description

This Java program asks the user for loan-applicant information and uses boolean logic to determine whether the applicant is eligible for a loan. It prints:

  • Eligibility Status (true/false)
  • Detailed explanation showing which rules passed/failed

Inputs

  • Age (integer)
  • Income (double)
  • Credit Score (integer)
  • Existing Debt (double)

Outputs

  • Eligibility Status (boolean)
  • Rule-by-rule explanation (PASSED/FAILED)

Boolean Logic Requirements (Must Include)

  • Use &&, ||, and !
  • Use nested conditions (if inside if or layered else if)
  • Use short-circuit logic in combined expressions

Loan Eligibility Rules

The applicant is eligible if ALL of these are true:

  • Age Rule: age >= 18 && age <= 65
  • Strength Rule: income >= 25000 || creditScore >= 700
  • Debt Rule: !(debt > 0.50 * income)
Reminder: Your program must validate inputs: age > 0, income > 0, credit score 300–850, debt >= 0.

Pseudocode

1. Input: Get user details (age, income, credit score, debt).
2. Validate inputs:
   - age > 0
   - income > 0
   - credit score between 300 and 850
   - debt >= 0
3. Apply rules with boolean logic:
   - ageRule = (age >= 18 AND age <= 65)
   - strengthRule = (income >= 25000 OR creditScore >= 700)
   - debtRule = NOT (debt > 0.5 * income)
4. eligible = ageRule AND strengthRule AND debtRule
5. Output eligibility status + detailed explanation (PASSED/FAILED for each rule).

Full Java Code (with comments)

import java.util.Scanner;
/*
 * File: PX_lastname_LoanBoolean.java
 * Boolean Logic Evaluator (Loan Eligibility)
 *
 * Skills:
 * - boolean expressions (&&, ||, !)
 * - nested if statements
 * - input validation
 * - short-circuit logic
 *
 * Output:
 * - eligibility (true/false)
 * - detailed rule-by-rule explanation
 *
 * Author: Joe Cusack
 * Date: 2/22/2026
 */

// ----- 1) INPUT -----

// ----- 2) VALIDATION -----

// Short-circuit: if any are false, stop and show errors

// ----- 3) BOOLEAN LOGIC RULES -----

// ----- 4) OUTPUT -----

// ----- 5) NESTED CONDITIONS DEMO -----

// Nested explanation: show the first major issue

// Reads an integer safely

// discard bad input

// Reads a double safely

// discard bad input

    // Prints a rule in PASSED/FAILED format
    private static void printRule(String ruleName, boolean passed, String passMsg, String failMsg) {
        System.out.println("\nRule: " + ruleName);
        System.out.println("Status: " + (passed ? "PASSED" : "FAILED"));
        System.out.println("Explanation: " + (passed ? passMsg : failMsg));
    }
}