This C++ program implements a simple casino game where players can bet on a number between 1 and 10. The player has the opportunity to win or lose money based on whether their chosen number matches the randomly generated dice roll. The game continues until the player decides to stop or runs out of money .
- Ensure you have a C++ compiler installed on your system.
- Copy the provided code into a C++ source file (e.g.,
guessnumber.cpp
). - Compile the code using your preferred C++ compiler.
- Run the compiled executable.
- Enter your name and initial deposit amount.
- Follow the on-screen instructions to place bets and guess a number between 1 and 10.
- If your guess matches the randomly generated number, you win 10 times your bet amount.
- If your guess is incorrect, you lose your bet amount.
- The game continues until you decide to stop or run out of money.
- Random Number Generation: The program uses the
rand()
function to generate a random number for the dice roll. - Input Validation: The code includes input validation to ensure that the entered bet amount and guess are within the valid range.
- Balance Tracking: The player's balance is displayed after each round, and the game ends if the player runs out of money.
- Enter your name and initial deposit.
- Follow the on-screen instructions to place bets and guess numbers.
- Enjoy the thrill of the game and try to increase your balance.
- The code uses the
system("cls")
function to clear the console screen, which may not work on all systems. Consider using platform-independent methods for clearing the screen if needed. - This is a simple casino game for educational purposes and does not involve real money .