If Statement Basics in Java
📖 Scenario: You are creating a simple program that checks if a person is old enough to vote. Voting age is 18 years or older.
🎯 Goal: Build a Java program that uses an if statement to check a person's age and print whether they can vote or not.
📋 What You'll Learn
Create an integer variable
age with the exact value 20Create an integer variable
votingAge and set it to 18Use an
if statement to check if age is greater than or equal to votingAgePrint
"You can vote!" if the condition is truePrint
"You cannot vote yet." if the condition is false💡 Why This Matters
🌍 Real World
Checking age eligibility is common in many apps, like voting, driving, or buying age-restricted items.
💼 Career
Understanding if statements is essential for decision-making in programming jobs.
Progress0 / 4 steps