본문 바로가기

자바

백준 알고리즘 - 9498번 시험 성적 [자바]

 

<문제 풀이>

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		if (a <= 100 & a >= 90) {
			System.out.print("A");
		} else if (a <= 89 & a >= 80) {
			System.out.print("B");
		} else if (a <= 79 & a >= 70) {
			System.out.print("C");
		} else if (a <= 69 & a >= 60) {
			System.out.print("D");
		} else {
			System.out.print("F");
		}
	}
}

이 문제는 딱히 어려운 것이 없었다.

scanner와 if문을 이용해서 범위만 정해주면 가능한 문제였다.