개발/Algorithm

[Java] 백준 9498번 삼항연산자로 해결

Dane.Kim 2021. 8. 31.

삼항 연산자로 깔끔하게 해결

package prac;

import java.util.Scanner;

public class bj9498 {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		sc.close();
		
		System.out.println((i>=90)? "A" : (i>=80)? "B" : (i>=70)? "C": (i>=60)? "D" : "F");
		
	}

}

 

'개발 > Algorithm' 카테고리의 다른 글

[Python] 랜덤 리스트 비교  (0) 2021.10.16
[Java] 백준 2292번 벌집  (0) 2021.09.27
[Python] 백준 2292번 벌집  (0) 2021.09.27
[Java] 백준 2753번 삼항연산자 이용법  (0) 2021.08.31
[Java] 설탕배달 (백준 2839번)  (0) 2021.08.30

댓글