https://www.acmicpc.net/problem/9498

 

9498번: 시험 성적

시험 점수를 입력받아 90 ~ 100점은 A, 80 ~ 89점은 B, 70 ~ 79점은 C, 60 ~ 69점은 D, 나머지 점수는 F를 출력하는 프로그램을 작성하시오.

www.acmicpc.net


백준 온라인 저지(BOJ)의 첫 번째 단계인 "if문"의 두 번째 문제이다.

 

이전 문제와 마찬가지로 if문의 기초적인 문제이다.

 

 

 

 

 

 

  • 첫 번째 방법 - Scanner
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		int score = Integer.parseInt(in.nextLine());
		
		if(score >= 90)
			System.out.println("A");
		else if(score >= 80)
			System.out.println("B");
		else if(score >= 70)
			System.out.println("C");
		else if(score >= 60)
			System.out.println("D");
		else
			System.out.println("F");
 	}
}

 

 

 

 

 

  • 두 번째 방법 - BufferedReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int score = Integer.parseInt(br.readLine());
		
		if(score >= 90)
			System.out.println("A");
		else if(score >= 80)
			System.out.println("B");
		else if(score >= 70)
			System.out.println("C");
		else if(score >= 60)
			System.out.println("D");
		else
			System.out.println("F");
 	}
}

BufferedReader가 Scanner에 비해 성능이 우수하기 때문에 시간적인 측면에서 첫 번째 방법보다 유리하다.

 

 

 

 

 

 

 

 


  • 느낀 점

...아직까지는 쉽다