Blackjack C Sharp

Im tasked with developing a simple blackjack program for a class. The program I have currently compiles and runs but it isnt paying out properly. A blackjack (21) should pay out 1.5*the wager, but it is doing it more than it should. Here is the code I have.

I know the problem is in my if else statements im just not sure how to make it work. Thanks for the help.

  • 3 Contributors
  • forum3 Replies
  • 4,671 Views
  • 7 Hours Discussion Span
  • commentLatest PostLatest Postby spookyfish

$ begingroup $ @RubberDuck, there are single deck Blackjack games still being played in Deadwood,SD at Saloon #10 I think it might be the only single deck game in Deadwood. (Last Time I was there to Play Blackjack) $ endgroup $ – Malachi ♦ Aug 21 '14 at 15:09. Let's hope your teacher doesn't know how to play blackjack! You're initially dealt 2 cards, before you hit or stay, not one. If you go over 21, and the dealer goes over 21, you do not win.

Recommended Answers

This may or may not be part of the problem, but it needs to be adressed:

I did the same thing when I was first learning boolean logic and performing tests, and it took me a long time to understand why things are the way they …

Jump to Post

All 3 Replies

This may or may not be part of the problem, but it needs to be adressed:

Blackjack c sharp piano

I did the same thing when I was first learning boolean logic and performing tests, and it took me a long time to understand why things are the way they are, but for now just trust me.... you would think the above is correct, but there is a specific way that boolean tests are handled, either in a singular expression, or a stand-alone variable (which yeilds true or false, non-zero and zero respectively)

Programming

So, keep in mind, boolean logic is handled individually per expression, or as a stand alone TRUE/FALSE flag.

spookyfishcommented:Helped me solve my problem really quickly!+0

Blackjack C Sharp Piano

Blackjack

This application uses one instance of the Random() class in the object rnd. It also allocates enough space to hold the totals for scores 3..18 in the array Rolls[]. MemberfunctionsOneDice() returns a value between 1 and 6 - rnd.Next(n) returns values in the range 0..n-1, while ThreeDice() calls OneDice() three times. The constructor for the RollDice() clears the Rolls array then calls ThreeDice() however many times (10 million in this case) and increments the appropriate Rolls[] element.

Blackjack C Sharp

Blackjack C Sharp Vs

The last part is to print out the generated totals to see that it generates throws in accordance with the probabilities. A 6 sided dice has an average score of 3.5, so three dice should average about 10.5. The totals for 10 and 11 are roughly the same and occur about 12.5% of the time.

Blackjack C Sharp

Here is the output of a typical run. It takes no more than a second. Because it's a console application, I included a

To wait until you hit a key before closing.

Program Output

C Sharp Programming Download

Program Listing