Pass or Fail (Ternary)
Easyjava
Learn the Concept: Ternary OperatorRead a mark and print Pass if it is at least 35, otherwise Fail. Use the ternary operator.
Input: one integer — the mark.
Output: one line — Pass or Fail.
Example 1
Input
40
Output
Pass
Example 2
Input
30
Output
Fail
- 0 <= mark <= 100
Hint 1
The condition is mark >= 35.
Hint 2
Assign the ternary result to a String and print it.
One condition, two possible values — the perfect fit for the ternary operator. mark >= 35 selects "Pass", anything else selects "Fail".
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- Larger Value (Ternary)Easy · javaSolve Problem
- Even or Odd (Ternary)Easy · javaSolve Problem
- Absolute Value (Ternary, No Math.abs)Easy · javaSolve Problem