오늘보다 더 나은 내일의 나에게_

백준 9498번_시험 성적_자바 본문

ALGORITHM/baekjoon_with_java

백준 9498번_시험 성적_자바

chan_96 2022. 1. 8. 08:52
728x90

문제

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

입력

첫째 줄에 시험 점수가 주어진다. 시험 점수는 0보다 크거나 같고, 100보다 작거나 같은 정수이다.

출력

시험 성적을 출력한다.

제한

-

예제 입력 1

100

예제 출력 1

A

 

 

코드

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int score = sc.nextInt();
		
		if(score >= 90 && score <= 101) {
			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");
		}
	}
}

 

풀이 및 정리

- Scanner 통해 점수 입력
- else if문을 통해 출력
728x90
Comments