4일차 *** 상점 *** (2)

Console Programming/C# Console 2019. 9. 23. 11:39
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax08
{
    class Program
    {
        static void Main(string[] args)
        {
            int goldNow = 5000;
            int priceLongSword = 800;
            int priceShortSword = 550;
            int priceBow = 760;
            int priceAxe = 810;
            Console.WriteLine("*** 상점 ***");
            Console.WriteLine("[장검, 단검, 활, 도끼]");
            Console.WriteLine("---------------------------");
            Console.WriteLine($"금화 : {goldNow}");
            Console.WriteLine("---------------------------");
            Console.WriteLine("1. 장검 : 800");
            Console.WriteLine("2. 단검 : 550");
            Console.WriteLine("3. 활 : 760");
            Console.WriteLine("4. 도끼 : 810");
            Console.Write("상점에서 구입 하고자 하는 아이템을 입력해주세요. ");
            string input = Console.ReadLine();
            if (input == "장검")
            {
                goldNow = goldNow - priceLongSword;
                Console.WriteLine($"{input}을 구매했습니다.({-priceLongSword})");
                Console.WriteLine("---------------------------");
                Console.WriteLine($"금화 : {goldNow}");
                Console.WriteLine("---------------------------");
            }
            else if (input == "단검")
            {
                goldNow = goldNow - priceShortSword;
                Console.WriteLine($"{input}을 구매했습니다.({-priceShortSword})");
                Console.WriteLine("---------------------------");
                Console.WriteLine($"금화 : {goldNow}");
                Console.WriteLine("---------------------------");
 
            }
            else if (input == "활")
            {
                goldNow = goldNow - priceBow;
                Console.WriteLine($"{input}을 구매했습니다.({-priceBow})");
                Console.WriteLine("---------------------------");
                Console.WriteLine($"금화 : {goldNow}");
                Console.WriteLine("---------------------------");
            }
            else if (input == "도끼")
            {
                goldNow = goldNow - priceAxe;
                Console.WriteLine($"{input}을 구매했습니다.({-priceAxe})");
                Console.WriteLine("---------------------------");
                Console.WriteLine($"금화 : {goldNow}");
                Console.WriteLine("---------------------------");
            }
            else
            {
                Console.WriteLine($"해당상품 (\"{input}\")는 없습니다.");
            }
                
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 

'Console Programming > C# Console' 카테고리의 다른 글

4일차 *** 상점 *** (4)  (0) 2019.09.23
4일차 *** 상점 *** (3)  (0) 2019.09.23
4일차 *** 상점 ***  (0) 2019.09.23
구구단 출력3 의 코드 수정  (0) 2019.09.21
2일차 ***별찍기2*** 의 코드 수정  (0) 2019.09.21
: