003-003-005

Logical Operators: Entry Check

Easy

Problem Description

Logical Operators: Entry Check

Learning Objective: Understand how to use AND operator(&&) and OR operator(||)

Create a program that inputs age and ticket status, then determines entry permission.
Entry condition: 18 years or older AND has ticket

Input

Line 1: Age (integer)
Line 2: Has ticket (true or false)

Output

Age: [age]
Ticket: [true/false]
Entry: [allowed/denied]
```java

## Example
Input:
```java
20
true
```java
Output:
```java
Age: 20
Ticket: true
Entry: allowed

Test Cases

※ Output examples follow programming industry standards

Input:
20
true
Expected Output:
Age: 20
Ticket: true
Entry: allowed
Input:
15
true
Expected Output:
Age: 15
Ticket: true
Entry: denied
Input:
18
false
Expected Output:
Age: 18
Ticket: false
Entry: denied
❌ 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);
// 年齢を読み込む
int age = sc.nextInt();
// チケットステータスを読む
boolean hasTicket = sc.nextBoolean();
// 入場条件をチェック(18歳以上かつチケット所持)
boolean canEnter = (age >= 18) && hasTicket;
// 結果を出力
System.out.println("Age: " + age);
System.out.println("Ticket: " + hasTicket);
System.out.println("Entry: " + (canEnter ? "allowed" : "denied"));
}
}

0 B / 5 MB

You have 10 free executions remaining