003-004-008

Using Logical Operators

Easy

Problem Description

Using Logical Operators

Learning Objective: Understand Java's logical operators (&&, ||, !) and express compound conditions

Overview

Create a program that inputs an age and uses logical operators to evaluate various conditions.

Specifications

  1. Input age as an integer
  2. Evaluate and output the following conditions as true/false:
    • Adult and not senior (18 or older AND under 65)
    • Child or senior (under 18 OR 65 or older)
    • Not adult (under 18)

Input Format

25

Output Format

Adult and not senior: true
Child or senior: false
Not adult: 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?