5일차 시험점수를 입력받아 학점으로 출력 (2) 논리연산자 사용

Console Programming/C# Console 2019. 9. 24. 11:05

논리 연산자 && 와  ||를 사용하여 구성하였다.

 

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
39
40
41
42
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax11
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("시험 점수를 입력하세요.");
            int score = Int32.Parse(Console.ReadLine());
            if (score < 0 || score >100)
            {
                Console.WriteLine("0~100사이의 값이 아닙니다.");
            }
            else if (score <= 100 && score >= 90)
            {
                Console.WriteLine("A");
            }
            else if (score <= 89 && score >= 80)
            {
                Console.WriteLine("B");
            }
            else if (score <= 79 && score >= 70)
            {
                Console.WriteLine("C");
            }
            else if (score <= 69 && score >= 60)
            {
                Console.WriteLine("D");
            }
            else
            {
                Console.WriteLine("F");
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

: