BAEKJOON/단계별로 풀어보기

[BOJ][C언어, Python, Java] 9498번 : 시험 성적

말하는 알감자 2022. 7. 25. 09:15

문제 링크 : https://www.acmicpc.net/problem/9498

🔒 문제

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

⌨ 입력

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

🖨 출력

시험 성적을 출력한다.

📚 예제

Ex)

100

A

🔑 python 코드

import sys
input = sys.stdin.readline

score = int(input())
if score >= 90:
    print("A")
elif score >= 80:
    print("B")
elif score >= 70:
    print("C")
elif score >= 60:
    print("D")
else:
    print("F")

🔑 java 코드

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");
    }

}

🔑 c언어 코드

#include <stdio.h>

int main()
{
    int grade;
    scanf("%d", &grade);

    if (grade >= 90)
        printf("A");
    else if (grade >= 80)
        printf("B");
    else if (grade >= 70)
        printf("C");
    else if (grade >= 60)
        printf("D");
    else
        printf("F");
    return 0;
}