005-005-007
Pass/Fail Judgment with Conditional Operator
Easy
Problem Description
Pass/Fail Judgment with Conditional Operator
In this problem, you will create a program that reads a score (integer) from standard input and uses the conditional (ternary) operator score >= 60 ? "Pass" : "Fail" to determine the result in a single expression, assigns it to String result, and prints it to standard output.
Input: A single integer value (score).
Output: Print Result: Pass or Result: Fail.
Learning Objectives:
- Learn the syntax and behavior of the conditional operator (
condition ? valueIfTrue : valueIfFalse) - Replace a simple if-else with a concise single-line expression
- Apply the ternary operator for conditional value assignment
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