-
Notifications
You must be signed in to change notification settings - Fork 3
/
Casino.cpp
103 lines (93 loc) · 2.11 KB
/
Casino.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
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
double money = 1000;
double bet;
char T;
int n, number;
double fmoney = 1000;
void chooseBet()
{
switch(number)
{
case 1:
bet = fmoney*0.1;
break;
case 2:
bet = fmoney*0.25;
break;
case 3:
bet = fmoney*0.5;
break;
case 4:
bet = fmoney;
break;
default:
cout << "Invalid entry. Try again!" << endl;
cin>>number;
chooseBet();
break;
}
}
int main()
{
system("cls");
do
{
srand (time(NULL));
int x = rand()%11;
cout << endl;
cout << "****Casino****" << endl;
cout << endl;
cout << "Khud ko champ samjhte ho? Then choose a number between 0 - 10:" << endl;
cin>>n;
cout << endl;
cout << "You have $1000 currently..." << endl;
cout << "Bet-" << endl;
cout << "1. 10% of your money" << endl;
cout << "2. 25% of your money" << endl;
cout << "3. 50% of your money" << endl;
cout << "4. Don't take me lightly, I will bet all of it!" << endl << endl;
cout << "Choose how much you want to bet: ";
cin>>number;
chooseBet();
if(x==n)
{
cout << "You won!" << endl;
fmoney += bet;
cout << "Current balance: $";
cout << fmoney << endl;
}
else
{
cout << "You lost... Wanna bet again?" << endl;
cout << "The number was : " << x << endl;
fmoney -= bet;
cout << "Current balance: $";
cout << fmoney << endl;
}
cout << "Do you have the guts to play again? (Y/N) : ";
cin>>T;
if(T == 'Y' || T =='y')
{
if(fmoney>0)
cout << "Great, Let's play again!" << endl;
else
cout << "You ran out of money!" << endl;
}
else if(T=='N' || T == 'n')
{
cout << "What a loser..." << endl;
break;
}
else
{
cout << "Invalid entry... Try again";
while (T!= 'Y' || T!= 'y' || T != 'N' || T!= 'n')
{
cin>>T;
}
}
}while(fmoney > 0);
return 0;
}