005-001-008

If Statement: Entrance Check

Easy

Problem Description

If Statement: Entrance Check

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

Test Cases

※ Output examples follow programming industry standards

Input:
20
Expected Output:
YourAge: 20 years old
Can Enter
Input:
15
Expected Output:
YourAge: 15 years old
Cannot Enter
Input:
18
Expected Output:
YourAge: 18 years old
Can Enter
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 5 free executions remaining