-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuessanumber.cpp
109 lines (90 loc) · 3.58 KB
/
Guessanumber.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
//CASINO GAME : NUMBER GUESSING PROGRAM
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
using namespace std;
void rules();
int main()
{
string name;
int amnt;
int bidamnt;
int guess;
int dice;
char choice;
srand(time(0)); //Use for generating random number each time
cout <<"\n===============================================================================================";
cout <<"\n CCCCC A SSSSSSSSS IIIIIIIII NN NN OOOOOOOO ";
cout <<"\n CC A A SS III NN N NN OO OO ";
cout <<"\nCC A A SSSSSSSSS III NN N NN OO OO ";
cout <<"\n CC AAAAAAAA SS III NN N NN OO OO ";
cout <<"\n CCCCC A A SSSSSSSSS IIIIIIIII NN NN OOOOOOOO ";
cout <<"\n===============================================================================================\n";
cout << "\nEnter Player Name : ";
getline(cin,name);
cout << "\nDeposit Your Amount : $ ";
cin >> amnt;
do
{
system("cls");
rules();
do
{
cout <<"\nWelcome"<<name<<"Are You Ready To Play?"<<"\n\n";
cout <<"Enter Bid Amount : $";
cin >> bidamnt;
if(bidamnt > amnt)
{
cout << "You Cannot Bid More Than The Current Amount"<<"\nRe-enter Amount";
}
}
while(bidamnt>amnt);
do
{
cout <<"Guess The Number Between 1 To 10 :";
cin >> guess;
if(guess <=0 || guess>10)
{
cout <<"\nNumber Should Be Between 1 to 10\n"<<"\nGuess Number Again: ";
}
}
while(guess<=0 || guess>10);
dice = rand()%10 + 1; //to generate numbers randomly bw 1 and 10
if(dice == guess)
{
cout <<"\n Congratulations !! You Won " << bidamnt*10 << "$";
amnt = amnt + bidamnt *10;
}
else
{
cout << "Sorry !! You Lose " << bidamnt <<"$\n";
amnt = amnt-bidamnt;
}
cout << "\nThe Winning Number Was: " <<dice <<"\n";
cout <<"\n"<<name<<",Your Remaining Amount Is "<<amnt<<"$\n";
if(amnt==0)
{
cout <<"\nSorry You Don't Have Money To Play\n";
break;
}
cout <<"\nYou Want To Play Again Press(y/n)?";
cin >> choice;
} while(choice =='Y'||choice=='y');
cout<<"\n===============================================================================================\n";
cout << "Thanks For Playing Game Again Your Current Amount Is " << amnt << "$";
cout<<"\n===============================================================================================\n";
return 0;
}
void rules()
{
system("cls");
cout << "\n===============================================================================================\n";
cout << "\t\t\tGame Rules";
cout << "\n===============================================================================================";
cout << "\n1. Choose Number Between 1 To 10";
cout << "\n2. Winning Amount Will Be 10 Times Of Bid Amount";
cout << "\n3. Loose Amount Will Be Biding Amount";
cout << "\n4. You Can Leave A Game Any Time";
cout << "\n===============================================================================================\n";
}