005-001-008
If Statement: Entrance Check
Easy
Problem Description
if statement: Entrance Check
In this problem, you will create a program that reads an age value and uses an if-else statement to determine whether the person is allowed to enter (18 or older) or not (under 18), then displays the result to standard output.
Learning Objective: Perform conditional judgment with if statement
Create program that inputs age and displays "can enter" for 18+, "cannot enter" for under 18. Use if-else statement for branching.
Input
Line 1: Age (integer)
Output
For 18+:
Your age: [age] years old
You can enter
```java
For under 18:
```java
Your age: [age] years old
You cannot enter
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up