If there are any aces in the hand, and the total exceeds 21, change the 11 to a 1 i. Just generate a random number, where 1 is an ace and 10, 11, 12, and 13 represent 10 as well. To get the right distribution of cards. Is that really what you want? This is a good example of when extracting the functionality into a shared method would have helped you out.
The dealer must hit if their card total is less than 17 or a soft 17and must stand if it is 17 or higher.
Letters for variable names don't cost the Earth In context, you can figure out what dhand, dhandSize, dhandSum mean. Face cards Kings, Queens, Jacks are worth 10 points, Aces are worth 1 or 11 points, and all other cards are worth their face value.
For the Player 3. If both players have 21, then the dealer is declared the winner. If you extract the functionality into another method can call it from both places the game will become that little bit fairer for the players.
The dealer shows one card face up, and the other is face down. Now i'm not asking for someone to write the program for me. However, they would be much more expressive if you pad them out with some missing letters: You ask the user some yes no questions and have the same values for the answer, so using a constant would really aid translation.
This code will be very difficult to follow without proper commenting. And unlike other people who post their programming assignments waiting for someone to write their program for them, i actually spent a lot of time on this but i simply cant get it.
Two cards are dealt to each new casino sites 2016 uk. For the Dealer 2. I know most of you guys will be like "we don't do homework for free" and all that stuff, but i honestly need help.
Whichever player gets closest to 21 without young black jack narrator it, wins.
You might want to have a constant for 21 possibly BlackJackparticularly since you have so many occurrences of it. Replacing them with constants could help the readability of your code and reduce the chance of bugs. The player has two choices: Consider adding a deck class that you initialise with 1 or more packs of shuffled cards when constructed then remove from the deck as each card is drawn.
Adding this type of generalisation would also make it easier for you to extend your program so that it could for example support multiple players against the dealer. Consider this from your main loop: Grading This is a difficult project that you should concentrate on correctness and readability.
This could be generalised if you were for example to add the concept of a Player dealers are players to, they're just automated to your class. You need to be able to also handle multiple aces. You can ignore suit.
For example it could have a method to CalculateScore, based on the cards it is holding. The assignment is as follows: The player gets to see both of his or her cards and the total of them is added. I have been out for quite a few classes and it's affected my ability to do this program.
Hit means to take another card. The checks you need to do are the same checks that are performed at the end of every round, except the end of round check supports a draw. MasterMathematician 15 So I have recently received a new assignment in class to create a blackjack program.
Constants are your friends There are several places in your code that could benefit from the removal of 'magic' numbers. What's in a deck When you're dealing cards, you're deciding what card to add using a random generator.
The globals should be removed, they're just going to cause confusion. This would make your draws more realistic and allow you to reuse the deck class in any future card games you may construct such as poker.
Members Vs Globals It's odd that you have global variables defined in your Blackjack. I will grade for correctness, readability, comments, and a separate grade for appearance of output screen.
But merely for someone to point me in the right direction and give me a few tips.