Problem

BOJ No.9498

example

Solution

Surely we can solve this by using if statements.
But here’s a brand new perspective (for me) on this; using a multiple conditional operator.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.print("Score: ");
        int score = sc.nextInt();
        sc.close();

        System.out.print((score>=90)? "A": (score>=80)? "B": (score>=70)? "C": (score>=60)? "D": "F");
    }
}
#include <stdio.h>

int main() {
    int score;
    scanf_s("%d", &score);
    printf("%c", (score>=90)? 'A': (score>=80)? 'B': (score>=70)? 'C': (score>=60)? 'D': 'F');
}

Result

Normal and desirable result comes up.

Source

BOJ-9498