005-004-009
Combining AND and OR
Hard
Problem Description
Combining AND and OR
In this problem, you will create a program that reads three values (role, department, level) from standard input, evaluates access rights using a compound condition combining AND and OR operators, and displays the result to standard output.
Learning Objective: Understand complex conditions combining AND and OR operators
Overview
Combine AND and OR to perform complex conditional evaluation.
Input Format
role
department
level
- Line 1:
role(String) - Line 2:
department(String) - Line 3:
level(int)
Specifications
- Output "Access granted" if role is "admin" OR (department is "IT" AND level >= 2)
- Otherwise output "Access denied"
Output Format
Access granted
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