상점에서 아이템 구매 2번(19.09.23)
Console(콘솔)/실습 2019. 9. 23. 14:06
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax05
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("[step2]");
Console.WriteLine("---------------------------------");
Console.WriteLine("금화 : 5000");
Console.WriteLine("---------------------------------");
Console.WriteLine("상품목록");
Console.WriteLine("---------------------------------");
Console.WriteLine("장검 : 800");
Console.WriteLine("단검 : 550");
Console.WriteLine("활 : 760");
Console.WriteLine("도끼 : 810");
Console.WriteLine("---------------------------------");
Console.WriteLine("상점에서 구입 하고자 하는 아이템을 입력해주세요.");
string str = Console.ReadLine();
Console.WriteLine("입력: " + str);
int maxmoney = 5000;
if (str == "장검")
{
Console.Write(str + "을 구매 했습니다.");
Console.WriteLine("(-800)");
Console.WriteLine("금화: " + (maxmoney - 800));
}
else if (str == "단검")
{
Console.Write(str + "을 구매 했습니다.");
Console.WriteLine("(-550)");
Console.WriteLine("금화: " + (maxmoney - 550));
}
else if (str == "활")
{
Console.Write(str + "을 구매 했습니다.");
Console.WriteLine("(-760)");
Console.WriteLine("금화: " + (maxmoney - 760));
}
else if (str == "도끼")
{
Console.Write(str + "을 구매 했습니다.");
Console.WriteLine("(-810)");
Console.WriteLine("금화: " + (maxmoney - 810));
}
else
{
Console.WriteLine("출력: 해당상품(\"" + str + "\")는 없습니다.");
}
|
'Console(콘솔) > 실습' 카테고리의 다른 글
상점에서 구매 후 구매 목록 작성(19.09.23) (0) | 2019.09.23 |
---|---|
상점에서 아이템 구매 3번(19.09.23) (0) | 2019.09.23 |
상점에서 아이템 구매 1번(19.09.23) (0) | 2019.09.23 |
if else를 이용한 줄넘기 입력 실패시 되돌리기(19.09.20) (0) | 2019.09.20 |
if-else 문을 사용한 줄넘기(19.09.20) (0) | 2019.09.20 |