//BlackJack //Classic Gambling game where the player counts to 21. #include #include #include using namespace std; const int NUM_CARDS_IN_DECK = 13; const int MAX_CARDS_IN_HAND = 11; int main () { char again = 'y'; char approach = 'y'; //code from deck maker start srand((unsigned int)time(0)); //seeds random numbers for game int deck[NUM_CARDS_IN_DECK]; int value[NUM_CARDS_IN_DECK] = { 14, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; char name[NUM_CARDS_IN_DECK] = { 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K' }; //deck end int randomNumber = rand(); //generate random number! int high = 21; int low = 10; int range = (high - low) + 1; int finalScore = 0; //starting spending money int startMoney = 120; finalScore += startMoney; int feePerRound = 20; int tableFee = feePerRound; //amount player pays to get cards/play one round. int dealerNumber = rand() % range + low; //random number between 1 and 21 (modified) int winnings = 0, moneyBet; //how much money the player will bet after seeing the cards. //deck maker start //initializing deck for( int i=0; i> approach; cout << "how Much would you like to bet ?: "; cin >> moneyBet; while (approach == 'y') { finalScore -= tableFee; int choice; cout << "\nYour two cards: "; hand[numCardsInHand] = deck[currentDeckPosition]; cout << "\n " << name[hand[0]] << "\n"; numCardsInHand++; currentDeckPosition++; hand[numCardsInHand] = deck[currentDeckPosition]; cout <<" " << name[hand[1]] << "\n"; cout << "\nYou have Currently: " <> choice; switch (choice) { case 1: cout << "" << value[hand[numCardsInHand]]; finalScore += moneyBet; break; case 2: finalScore += tableFee; cout << "you were dealt: " << name[hand[numCardsInHand]]; numCardsInHand++; currentDeckPosition++; //put something here like if handValueTotal > 21 = bust! break; case 3: cout << "how Much?: "; cin >> moneyBet; break; case 4: cout << "\nYour total winnings are: " << finalScore <<"\n"; system ("pause"); return 0; default: cout << "you didnt enter 1,2, or 3./n"; } }while (again == 'y') { cout << "\n Do you want to play again?(y/n): "; cin >> again; } cout << "\nYour total winnings are: " << finalScore; system ("pause"); return 0; }