BlackJack

Write a C++ program to simulate the card game 21 for a single player against the computer. Deal 2 cards to the computer, but only show one, and 2 cards face up to the player. Ask the player if he would like an extra card and deal one each time he answers y. If he answers n or busts (card total is greater than 21). If he busts thank the player for playing and ask if he would like to play again. If he doesn’t, the computer then shows it’s second card and proceeds to hit until it reaches 17 or busts. If it is a tie, both players lose. There are 52 cards in a deck, face cards should be replaced by 10’s, and Aces replaced by 11’s unless they would cause a bust, then they become 1’s. If there is more than one ace in the hand only one at a time becomes a one. No card may be chosen twice, after an index is selected and it’s value is stored, the index element should be changed to -1 before the next card is drawn. If -1 is drawn it should be ignored and another card should be drawn. If neither the player nor the computer busts, the person whose card total is closer to 21 wins. The computer should then ask if the player wants to play again and repeat the game if the player answers y and thank the player and exit if the player answers no. Please do not use bool, and keep all functions in the same file. I am using the code::blocks compiler. Comments would also be greatly appreciated as I am just learning. Also, please name a fair price. I would make an offer, but I don’t know what fair is and don’t want to insult you. Thank you for reading this.

×
New Download