-
Notifications
You must be signed in to change notification settings - Fork 0
/
03.21.pick_a_card.cpp
135 lines (105 loc) · 3.31 KB
/
03.21.pick_a_card.cpp
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
125
126
127
128
129
130
131
132
133
134
135
#include <iostream>
/*
=====================================================================================
03.21. Game: pick a card
by : #bayuyudhasaputra
lang : IDN (Bahasa Indonesia)
-------------------------------------------------------------------------------------
Masalah :
Tuliskan suatu program yang mensimulasikan pengambilan 52 kartu remi. Program harus
menampilkan rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) dan suit
(Clubs, Diamonds, Hearts, Spades) dari kartu remi tersebut.
======================================================================================
*/
int main()
{
// 1. Input rank
std::cout << "Input rank : ";
unsigned short indeksRank;
std::cin >> indeksRank;
std::cout << std::endl;
// 2. Input suit
std::cout << "Input suit : ";
unsigned short indeksSuit;
std::cin >> indeksSuit;
std::cout << std::endl;
// 4. Cek indeks rank dan suit
if ((1 <= indeksRank && indeksRank <= 14) &&
(1 <= indeksSuit && indeksSuit <= 4))
{
std::cout << "Anda memilih ";
// Cek indeksRank
switch (indeksRank)
{
case 1:
std::cout << "As ";
break;
case 2:
std::cout << "2 ";
break;
case 3:
std::cout << "3 ";
break;
case 4:
std::cout << "4 ";
break;
case 5:
std::cout << "5 ";
break;
case 6:
std::cout << "6 ";
break;
case 7:
std::cout << "7 ";
break;
case 8:
std::cout << "8 ";
break;
case 9:
std::cout << "9 ";
break;
case 10:
std::cout << "10 ";
break;
case 11:
std::cout << "Jack ";
break;
case 12:
std::cout << "Queen ";
break;
case 13:
std::cout << "King ";
break;
}
// Cek indeksSuit
switch (indeksSuit)
{
case 1:
std::cout << "clubs";
break;
case 2:
std::cout << "diamonds";
break;
case 3:
std::cout <<"Hearts";
break;
case 4:
std::cout << "Spades";
break;
}
std::cout << "." << std::endl;
}
else
{
std::cout << "Input indeks Rank dengan bilangan 1, 2, 3, ..., 13 saja"
<< std::endl;
std::cout << "Input dengan bilangan 1, 2, 3, atau 4 saja"
<< std::endl;
}
return 0;
}
/*
Liang. 2014. Introduction to Programming with C++ 3rd Edition.
London : Pearson Education.
https://www.pearson.com/en-us/subject-catalog/p/Liang-Companion-Website-for-Introduction-to-Programming-with-C-Access-to-Videonotes-3rd-Edition/P200000003422/978013338026
*/