Larger of Two (No Math.max)
Easyjava
Learn the Concept: Relational OperatorsRead two integers and print the larger one, using a relational comparison (do not use Math.max).
Input: two integers separated by whitespace.
Output: one line — the larger value (or either one if they are equal).
Example 1
Input
5 3
Output
5
Example 2
Input
2 9
Output
9
- -1000000000 <= a, b <= 1000000000
Hint 1
Use if (a > b) ... else ...
Hint 2
When they are equal, printing either is fine.
Compare with >; if a is greater print a, otherwise print b. This also covers the equal case correctly.
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- Compare Two Numbers Six WaysEasy · javaSolve Problem
- Is It In Range?Easy · javaSolve Problem
- Sign of a NumberEasy · javaSolve Problem