C#

[백준] 9498번 시험성적 C# 풀이

오늘의 기록, 오록 2019. 9. 21. 00:31

시험 점수를 입력 받아 90~100점은 A, 80~89점은 B, 70~79점은 C, 60~69점은 D

그리고 나머지 점수는 F를 출력하는 프로그램을 작성하는 문제이다.

 

입력값이 특정 범위에 속하면 출력되는 값을 지정해주도록 작성하면 된다.

 

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
using System;
public class MainClass
{
    public static void Main()
    {
        string value = Console.ReadLine();
        string result = "";
        int testValue = Convert.ToInt32(value);
 
        if (testValue >= 0 && testValue <= 100)
        {
            if (testValue >= 90 && testValue <= 100)
                result = "A";
            else if (testValue >= 80 && testValue <= 89)
                result = "B";
            else if (testValue >= 70 && testValue <= 79)
                result = "C";
            else if (testValue >= 60 && testValue <= 69)
                result = "D";
            else
                result = "F";
 
 
            Console.WriteLine(result);
        }
 
    }
}
cs