003-003-012

Basic Logical Operators

Easy

Problem Description

Basic Logical Operators

In this problem, you will create a program that reads age (integer) and hasLicense (boolean) from standard input, performs three logical operations using && (AND), || (OR), and ! (NOT), and displays the results to standard output.

Learning Objective: Understand the behavior of Java logical operators (AND, OR, NOT)

Overview

Logical operators combine boolean values for condition evaluation. The three basics are && (AND), || (OR), and ! (NOT).

Input Format

age
hasLicense
  • Line 1: an integer representing age
  • Line 2: a boolean representing whether the person has a license (true or false)

Specifications

  • Read age and hasLicense from standard input
  • Display result of age >= 18 && hasLicense
  • Display result of age < 16 || hasLicense
  • Display result of !hasLicense

Output Format

Can drive: [true/false]
Has either condition: [true/false]
No license: [true/false]

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