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
In this problem, you will create a program that reads an integer age, uses an if statement to determine whether the person is 18 or older, and displays either "Adult" or "Minor" to standard output.
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").
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