003-002-014
Comparison Operators and Condition Evaluation
Medium
Problem Description
Comparison Operators and Condition Evaluation
In this problem, you will create a program that reads two int variables a and b from standard input, applies six comparison operators (==, !=, <, >, <=, >=), and displays the boolean result (true/false) of each operation with labels to standard output.
Learning Objective: Understand the behavior of Java comparison operators (==, !=, <, >, <=, >=)
Overview
Comparison operators compare two values and return boolean (true or false). They are used in conditional branching and loop conditions.
Specifications
- Read int values
aandbfrom standard input, one per line - Display results of each comparison operator with labels
Input Format
a
b
Output Format
a == b: [true/false]
a != b: [true/false]
a < b: [true/false]
a > b: [true/false]
a <= b: [true/false]
a >= b: [true/false]
Sample I/O
Input:
10
20
Output:
10 == 20: false
10 != 20: true
10 < 20: true
10 > 20: false
10 <= 20: true
10 >= 20: 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