004-001-007
If Statement: Age Eligibility
Easy
Problem Description
If Statement: Age Eligibility
Learning Objective: Perform conditional branching with if statement and execute appropriate processing
Determine if input age is 18 or older. Display different messages based on condition.
Input
Line 1: Age (integer)
Output
If 18 or older:
Age: [age] years old
Adult
```java
If under 18:
```java
Age: [age] years old
Minor
```java
## Examples
### Example 1: 18 or Older
Input:
```java
20
```java
Output:
```java
Age: 20 years old
Adult
```java
20 >= 18 so "Adult"
### Example 2: Under 18
Input:
```java
15
```java
Output:
```java
Age: 15 years old
Minor
```java
15 < 18 so "Minor"
### Example 3: Exactly 18 (Boundary)
Input:
```java
18
```java
Output:
```java
Age: 18 years old
Adult
```java
18 >= 18 so "Adult" (boundary value is included in "or older").
Test Cases
※ Output examples follow programming industry standards
Input:
20
Expected Output:
Age: 20 years old Adult
Input:
15
Expected Output:
Age: 15 years old Minor
Input:
18
Expected Output:
Age: 18 years old Adult
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
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 10 free executions remaining
