If-else statement
📖 Scenario: You are creating a simple program to check if a person is old enough to vote. In many countries, the voting age is 18 years.
🎯 Goal: Build a Java program that uses an if-else statement to decide if a person can vote based on their age.
📋 What You'll Learn
Create an integer variable called
age with the value 20.Create an integer variable called
votingAge with the value 18.Use an
if-else statement to check if age is greater than or equal to votingAge.Print
"You can vote." if the person is old enough.Print
"You cannot vote yet." if the person is too young.💡 Why This Matters
🌍 Real World
If-else statements help computers make choices, like checking if someone can vote or not.
💼 Career
Understanding if-else is essential for programming jobs because decision-making is everywhere in software.
Progress0 / 4 steps