Can help? My casino code always fail to build.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
char PlayerName[40]; // Player name
int b_amount; // Current balance amount.
int amount_BET; // Amount to be betted.
int number; // Number bet by a player.
int r_number; // Number chosen randomly.
char choice; // Asks a player to play again.
cout << "Welcome to the Casino!" <<endl;
cout << "Enter your name (up to 40 characters): ";
cin >> PlayerName;
cout<<endl<<endl;
cout << "Enter the amount to deposit: $";
cin >> b_amount;
do
{
cout << "Current balance: $"<< b_amount <<endl;
do
{
// GAME START
cout << "Enter the amount you want to bet: $";
cin >> amount_BET;
if (amount_BET > b_amount)
{
cout << "The amount you bet is more than your current balance. Please re-enter." <<endl;
}
else
{
break;
}
} while(1);
do
{
// BET A NUMBER
cout << "Enter a number to bet (1 - 12): ";
cin >> number;
if (number < 1 && number > 12)
{
cout << "The number you entered is out of range. Please re-enter (1 - 12)." <<endl;
}
else
{
break;
}
} while (1);
// PROCESS
srand( time(NULL) );
r_number = rand(12) + 1;
// RESULT
if (r_number == number)
{
amount_BET = amount_BET * 10;
cout << "Lucky! You won $" << amount_BET <<endl;
b_amount = b_amount + amount_BET;
}
else
{
cout << "I'm sorry, you didn't win this time." <<endl;
cout << "You lost $" << amount_BET <<endl;
b_amount = b_amount - amount_BET;
}
cout << "Winning number: " << r_number <<endl;
cout << "Current balance: $" << b_amount <<endl<<endl;
cout << "Do you want to play again? (y/n): ";
cin >> choice;
} while (choice = 'y');
cout << "Current balance: $" << b_amount <<endl;
cout << "Thank you for playing!" <<endl;
system ("pause");
return 0;
}