005-004-011

Logical Operators Basics

Easy

Problem Description

Logical Operators Basics

In this problem: You will create a program that demonstrates logical operators (&&, ||, !) with boolean variables, performs eligibility checks (age >= 18 AND has license), and displays the results including short-circuit evaluation behavior to standard output.

Learning Objective: Understand basic usage of logical operators and the concept of short-circuit evaluation

Overview

Perform the following operations:

  1. Check eligibility with age = 20, hasLicense = true and display result
  2. Check eligibility with age = 16, hasLicense = true and display result
  3. Display || operator result for "member or student" check
  4. Display ! operator result for boolean negation

Specifications

  • Determine eligibility with eligible = (age >= 18) && hasLicense
  • Set isMember = false, isStudent = true and evaluate isMember || isStudent
  • Set isRaining = false and evaluate !isRaining

Output Format

Age: 20, Has License: true -> Eligible: true
Age: 16, Has License: true -> Eligible: false
isMember || isStudent: true
!isRaining: true

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