Open itsshivamku opened 1 year ago
using namespace std;
void rules();
int main()
{
string playerName;
int balance;
int bettingAmount;
int guess;
int dice;
char choice;
srand(time(0));
cout << "\n\t\t=====WELCOME TO CASINO WORLD==\n\n";
cout << "\nwhat is your Name : ";
getline(cin, playerName);
cout << "\n\nenter the startin balance to play game :";
cin >> balance;
do
{
system("cls");
rules();
cout<<"\n\nyour current balance is :" << balance << "\n";
do
{
cout<<"Hey,"<<playerName<<",enter amount to bet :";
cin>>bettingAmount;
if(bettingAmount > balance)
cout<<"betting balance can't be more than current balance!\n"
<<"\nRe-enter balance\n ";
}
while(bettingAmount>balance);
do
{
cout<<"guess any betting number between 1 to 10 :";
cin>>guess;
if(guess<= 0||guess>10)
cout<<"\nNumber should be between 1 to 10\n"
<<"re-enter number:\n ";
}while(guess<=0||guess>10);
dice=rand()%10+1;
if(dice==guess)
{
cout<<"\n\nyou are in win,You have won Rs."<<bettingAmount10;
balance=balance+bettingAmount10;
}
else
{
cout<<"oops, better luck next time , you lost Rs "<< bettingAmount <<"\n";
balance = balance - bettingAmount;
}
cout<<"\nThe winning number was : "<<dice<<"\n";
cout<<"\n"<<playerName<<", you have balance of Rs "<<balance<<"\n";
if(balance==0)
{
cout<<"you have no money to play ";
break;
}
cout<<"\n\n-->do you want to play again (yes/no)? ";
cin>>choice;
}while(choice=='Yes'||choice=='yes');
cout << "\n\n\n";
cout << "\n\nthank you for playing the game. Your balance is Rs "<<balance<<"\n\n";
return 0;
}
void rules()
{
system("cls");
cout << "\t\t======CASINO NUMBER GUESSING RULES!======\n";
cout << "\t1.choose a number between 1 to 10\n";
cout << "\t2.winner get 10 times of the money bet\n";
cout << "\t3.wrong bet, and you lose the amount you bet\n\n";
}
include
include
include
include
using namespace std; void rules(); int main() { string playerName; int balance; int bettingAmount; int guess; int dice;
char choice; srand(time(0));
cout << "\n\t\t=====WELCOME TO CASINO WORLD==\n\n"; cout << "\nwhat is your Name : "; getline(cin, playerName); cout << "\n\nenter the startin balance to play game :"; cin >> balance; do { system("cls"); rules(); cout<<"\n\nyour current balance is :" << balance << "\n"; do { cout<<"Hey,"<<playerName<<",enter amount to bet :"; cin>>bettingAmount; if(bettingAmount > balance) cout<<"betting balance can't be more than current balance!\n" <<"\nRe-enter balance\n "; } while(bettingAmount>balance); do { cout<<"guess any betting number between 1 to 10 :"; cin>>guess; if(guess<= 0||guess>10) cout<<"\nNumber should be between 1 to 10\n" <<"re-enter number:\n "; }while(guess<=0||guess>10); dice=rand()%10+1; if(dice==guess) { cout<<"\n\nyou are in win,You have won Rs."<<bettingAmount10; balance=balance+bettingAmount10; } else { cout<<"oops, better luck next time , you lost Rs "<< bettingAmount <<"\n"; balance = balance - bettingAmount; } cout<<"\nThe winning number was : "<<dice<<"\n"; cout<<"\n"<<playerName<<", you have balance of Rs "<<balance<<"\n"; if(balance==0) { cout<<"you have no money to play "; break; } cout<<"\n\n-->do you want to play again (yes/no)? "; cin>>choice; }while(choice=='Yes'||choice=='yes'); cout << "\n\n\n"; cout << "\n\nthank you for playing the game. Your balance is Rs "<<balance<<"\n\n"; return 0; } void rules() { system("cls"); cout << "\t\t======CASINO NUMBER GUESSING RULES!======\n"; cout << "\t1.choose a number between 1 to 10\n"; cout << "\t2.winner get 10 times of the money bet\n"; cout << "\t3.wrong bet, and you lose the amount you bet\n\n"; }