switch 문
C#/실습 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
|
'C# > 실습' 카테고리의 다른 글
10.01 여러 class를 이용해 햄버거 세트 만들기 (0) | 2019.10.01 |
---|---|
워크래프트 캐릭생성하기 (0) | 2019.09.27 |
09.24 최대공약수 구하기 (0) | 2019.09.24 |
09.23 상점 구매하기 및 판매하기 (0) | 2019.09.23 |
09.20 줄넘기 (0) | 2019.09.20 |