Nested if statements
📖 Scenario: You are creating a simple program to check a person's age and citizenship to decide if they are eligible to vote.
🎯 Goal: Build a Java program that uses nested if statements to check if a person is at least 18 years old and is a citizen. If both conditions are true, print "Eligible to vote"; otherwise, print "Not eligible to vote".
📋 What You'll Learn
Create an integer variable
age with the value 20Create a boolean variable
isCitizen with the value trueUse nested
if statements to check age and isCitizenPrint the exact text "Eligible to vote" if conditions are met
Print the exact text "Not eligible to vote" if conditions are not met
💡 Why This Matters
🌍 Real World
Checking eligibility for voting is a common real-world decision based on multiple conditions like age and citizenship.
💼 Career
Understanding nested if statements is essential for writing clear decision-making code in many programming jobs.
Progress0 / 4 steps