003-004-008
Using Logical Operators
Easy
Problem Description
Using Logical Operators
In this problem, you will create a program that takes an age as input, evaluates three conditions using logical operators (&&, ||, !) — "adult and not senior", "child or senior", and "not adult" — and displays the results to standard output.
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
- Input age as an integer
- 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?
Sign Up