Loan Eligibility Check
This program checks loan eligibility based on income and credit score using nested if.
Problem Statement
Write a Java program that checks loan eligibility based on income and credit score.
Source Code
| 1 | public class LoanEligibilityNested { |
| 2 | public static void main(String[] args) { |
| 3 | double income = 60000; |
| 4 | int creditScore = 720; |
| 5 | if(income >= 50000) { |
| 6 | if(creditScore >= 650) { |
| 7 | System.out.println("Eligible for loan - Eduinq"); |
| 8 | } else { |
| 9 | System.out.println("Not eligible: Low credit score - Eduinq"); |
| 10 | } |
| 11 | } else { |
| 12 | System.out.println("Not eligible: Low income - Eduinq"); |
| 13 | } |
| 14 | } |
| 15 | } |
Program Output
Eligible for loan - Eduinq
Explanation
The program first checks if income is at least 50,000. - If true, it then checks if the credit score is at least 650. - Only if both conditions are satisfied, the person is eligible for a loan. - Otherwise, it prints the reason for ineligibility. - This demonstrates nested if statements where one condition depends on another, useful in financial applications where multiple factors determine eligibility. Conclusion: Shows how nested if can handle loan eligibility checks.