Post

[BOJ 2754] 학점계산

Baekjoon Online Judge 2754(Java 11)
[학점계산] 문제 풀이

[BOJ 2754] 학점계산

-> 문제 바로가기



시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초128 MB48987279822601457.913%

문제


  • 어떤 사람의 C언어 성적이 주어졌을 때, 평점은 몇 점인지 출력하는 프로그램을 작성하시오.

    • A+: 4.3, A0: 4.0, A-: 3.7
    • B+: 3.3, B0: 3.0, B-: 2.7
    • C+: 2.3, C0: 2.0, C-: 1.7
    • D+: 1.3, D0: 1.0, D-: 0.7
    • F: 0.0


입력


  • 첫째 줄에 C언어 성적이 주어진다. 성적은 문제에서 설명한 13가지 중 하나이다.


출력


  • 첫째 줄에 C언어 평점을 출력한다.


예제


1
2
// 입력
A0
1
2
// 출력
4.0


비슷한 문제



알고리즘 분류








제출



내 제출


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.*;
import java.util.*;

public class Main {
    public static void solution() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        Map<String, Double> grade = new HashMap<>();
        grade.put("A+", 4.3);
        grade.put("A0", 4.0);
        grade.put("A-", 3.7);
        grade.put("B+", 3.3);
        grade.put("B0", 3.0);
        grade.put("B-", 2.7);
        grade.put("C+", 2.3);
        grade.put("C0", 2.0);
        grade.put("C-", 1.7);
        grade.put("D+", 1.3);
        grade.put("D0", 1.0);
        grade.put("D-", 0.7);
        grade.put("F", 0.0);

        String alphabet = br.readLine();
        double answer = grade.get(alphabet);

        bw.write(String.valueOf(answer));

        bw.flush();
        bw.close();
        br.close();
    }

    public static void main(String[] args) throws IOException {
        solution();
    }
}


런타임메모리
100 ms14236 KB


Reference


This post is licensed under CC BY 4.0 by the author.