Travel Eligibility Check

This program checks travel eligibility based on passport, visa, and ticket status.

Problem Statement

Write a Java program that checks if a person is eligible to travel abroad based on passport, visa, and ticket status.

Source Code

1 public class TravelEligibility {
2 public static void main(String[] args) {
3 boolean hasPassport = true;
4 boolean hasVisa = true;
5 boolean hasTicket = false;
6 if(hasPassport && hasVisa && hasTicket) {
7 System.out.println("Eligible to travel abroad - Eduinq");
8 } else {
9 System.out.println("Not eligible to travel abroad - Eduinq");
10 }
11 }
12 }

Program Output

Not eligible to travel abroad - Eduinq

Explanation

The program checks three conditions: the person must have a passport, visa, and ticket. All conditions must be true for travel eligibility, so the program uses logical AND. If any condition fails, the else block prints not eligible. This demonstrates how multiple conditions can be combined to make decisions based on several factors, common in travel scenarios. Shows how multiple conditions determine travel eligibility.

Quick Links to Explore