Blackjack Solution




Your main game loop should ask the user how many players, and allow that many players to play the game. You may assume a max of 6 players.

You should allow your players to wager some amount of money on each play. You need to take in user input! I assume this means that you should not automate your game. You should make it so that 1-6 real people could use your program to play your game on 1 computer.

Your program follows all of the rules of blackjack specified in the assignment:

Each round of simplified blackjack proceeds as follows:


  1. The dealer shuffles the deck and deals two cards “face up” (with the front of the card showing) to each player.
  2. The dealer deals one card “face down” (with only the back showing) and one card “face up” to himself.
  3. The dealer asks the first player whether she wishes to “hit” (receive another card) or “stand” (not receive any more cards).
    1. If she chooses to stand, she will not receive any more cards this round, so her score is fixed. The game moves on to the next player.
    2. If she chooses to hit, the dealer will deal her another card, face up, and her score increases. She will then be given the option to hit or stand again.
    3. If her score exceeds 21, she has “busted” and immediately loses this round – play will continue with the next player.
    4. Essentially, the player can continue to hit until she either decides to stand, or busts.
  4. The hit-or-stand process is then repeated for each other player.
  5. Once all players are done, it is the dealer’s turn to play. First, he turns his face-down card over. Then he hits until his score is 17 or higher. The dealer cannot decide to hit or stand arbitrarily. If his score is less than 17, he must hit. If it is 17 or higher, he must stand.
  6. If the dealer busts, any players who did not bust earlier win this round. Otherwise, each player’s score is compared to that of the dealer. A player wins if he has a higher score than the dealer, loses if he has a lower score, and “pushes” (ties) if he has the same score.

At the end of each round, the group of players can decide whether they would like to play again.

Make sure everything that is calculated works properly! Here are the guidelines for results of a round:

Each hand will result in one of the following events for the player:

  • Lose – the player’s bet is taken by the dealer.
  • Win – the player wins as much as he bet. If you bet $10, you win $10 from the dealer (plus you keep your original bet, of course.)
  • Blackjack (natural) – the player wins 1.5 times the bet. With a bet of $10, you keep your $10 and win a further $15 from the dealer.
  • Push – the hand is a draw. The player keeps his bet, neither winning nor losing money.


Now that you have the basics of the game play, expand your game to include a wagering system. Give each player a bankroll to start with, then allow him/her to wager on the game. You should end the game with the output of each player’s ending balance.

error: Content is protected !!