C#/실습
switch 문
미고렝
2019. 9. 26. 13:14
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _09._26_step1
{
class Program
{
static void Main(string[] args)
{
string itemname = "장검";
/*switch (itemname)
{
case "장검":
Console.WriteLine("장검을 선택했습니다.");
break;
case "단검":
Console.WriteLine("단검을 서낵했습니다.");
break;
default:
Console.WriteLine("{0}을 선택할 수 없습니다.", itemname);
break;
}
*/
/*if (itemname == "장검")
{
Console.WriteLine("장검을 선택했습니다");
}
else if (itemname == "단검")
{
Console.WriteLine("단검을 선택했습니다");
}
else
{
Console.WriteLine("{0}을 선택했습니다.", itemname);
}*/
string input = Console.ReadLine();
switch(input)
{
case "1":
Console.WriteLine("안녕하세요");
break;
case "2":
Console.WriteLine("반갑습니다");
break;
default:
Console.WriteLine("감사합니다.");
break;
}
Console.WriteLine("성적을 입력하세요");
string score = Console.ReadLine();
switch (score)
{
case "a":
Console.WriteLine("90~100");
break;
case "b":
Console.WriteLine("80~89");
break;
case "c":
Console.WriteLine("70~79");
break;
case "d":
Console.WriteLine("60~69");
break;
case "f":
Console.WriteLine(0);
break;
}
Console.WriteLine("달 입력");
string month = Console.ReadLine();
switch (month)
{
case "1":
case "3":
case "5":
case "7":
case "8":
case "10":
case "12":
Console.WriteLine(31);
break;
case "4":
case "6":
case "9":
case "11":
case "2":
Console.WriteLine(30);
break;
default:
Console.WriteLine(-1);
break;
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|