상점에서 구매 후 구매 목록 작성(19.09.23)
Console(콘솔)/실습 2019. 9. 23. 16:51
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax06
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("[step4]");
Console.WriteLine("화면을 새로고침하세요.");
Console.WriteLine("구매 할때마다 구매한 목록과 금화를 출력 하세요.");
int count1 = 0;//장검 갯수
int count2 = 0;//단검 갯수
int count3 = 0;//활 갯수
int count4 = 0;//도끼 갯수
int max = 5000;//전재산
int str5 = 0;//쓴 돈
for (int a = 0; 0 < max;)
{
Console.WriteLine("---------------------");
Console.WriteLine("상품 목록");
Console.WriteLine("---------------------");
Console.WriteLine("장검 : 800");
Console.WriteLine("단검 : 550");
Console.WriteLine("활 : 760");
Console.WriteLine("도끼 : 810");
Console.WriteLine("---------------------");
Console.WriteLine("남은 금화 : " + max);
Console.WriteLine("---------------------");
Console.WriteLine("구매목록");
Console.WriteLine("---------------------");
if (count1 > 0)
{
Console.WriteLine("장검: x " + count1);
}
if (count2 > 0)
{
Console.WriteLine("단검: x " + count2);
}
if (count3 > 0)
{
Console.WriteLine("활: x " + count3);
}
if (count4 > 0)
{
Console.WriteLine("도끼: x " + count4);
}
Console.WriteLine("---------------------");
Console.Write("구입 하실 상품을 입력하시오. ");
string str = Console.ReadLine();
Console.WriteLine("입력: " + str);
Console.Clear();
if (str == "장검")
{
str5 = 800;
if (0 < max - str5)
{
max = max - str5;
count1++;
Console.Clear();
}
else
{
Console.WriteLine("\"" + "금화가 부족합니다." + "\"");
}
}
else if (str == "단검")
{
str5 = 550;
if (0 < max - str5)
{
max = max - str5;
count2++;
Console.Clear();
}
else
{
Console.WriteLine("\"" + "금화가 부족합니다." + "\"");
}
}
else if (str == "활")
{
str5 = 760;
if (0 < max - str5)
{
max = max - str5;
count3++;
Console.Clear();
}
else
{
Console.WriteLine("\"" + "금화가 부족합니다." + "\"");
}
}
else if (str == "도끼")
{
str5 = 810;
if (0 < max - str5)
{
max = max - str5;
count4++;
Console.Clear();
}
else
{
Console.Clear();
Console.WriteLine("\"" + "금화가 부족합니다." + "\"");
}
}
else
{
Console.WriteLine("해당 상품 (" + "\"" + str + "\"" + ")은(는) 상품이 아닙니다.");
}
}
}
}
}
|
'Console(콘솔) > 실습' 카테고리의 다른 글
상품 구매 갯수 선택 및 재고목록(19.09.23) (0) | 2019.09.23 |
---|---|
상품 구매 및 판매(19.09.23) (0) | 2019.09.23 |
상점에서 아이템 구매 3번(19.09.23) (0) | 2019.09.23 |
상점에서 아이템 구매 2번(19.09.23) (0) | 2019.09.23 |
상점에서 아이템 구매 1번(19.09.23) (0) | 2019.09.23 |