C Blackjack Program

 
C Blackjack Program Average ratng: 8,9/10 2321 reviews

My C Blackjack program is almost done, but as of right now, the program automatically runs hold or draw for everyone, and displays the final table instantly. I need to have the players choose hold or draw for themselves, and only the dealer be automatic. Also, each round of selection should show a new, updated table with the newly drawn cards. One direction where we can take our programming skills is game development. Here, we'll build a text based Blackjack engine that allows us to play against a dealer, who follows conventional house rules. The logic of blackjack is simple, but is sufficiently complex that we can gain valuable experience for making more complicated games later on. As we said, this engine has several. C Blackjack program. Part I: Here is one way to draw a random card from a deck. Create a string called “suit” that contains the characters CDHS, which stand for Clubs, Diamonds, Hearts, and Spades.

888casino is a multiple award-winning online casino that first opened its doors back in 1997. Today it boasts over 1000 top games enjoyed by over 17 million players worldwide. 888casino is licensed and regulated by the UK Gambling Commission and the Governments of Gibraltar and Malta. 888 Holdings plc has been listed on the London Stock Exchange since 2005. 88casino offers a wide. C blackjack game. Something very simple for beginer class. This is the assignment: The project will consist of creating a Black Jack game simulation using C. In the simulation a player will play against the computer. The simulation will utilize a 2 dimensional array to store the values of the card ranks. The implementation should use techniques learned this semester such as objects with.

I'd rather not help you with your homework for whatever programming class you might be taking. If you really care at all about programming, put in the effort to debug it yourself. Figure out the problem. Usually it's pretty obvious when there's an output error. Anyway, before people yell at me or whatever because he didn't say this is homework, read the prompt he provided :
Create a program in which a user plays a simple version of the card game 21 against the computer. Each player is initially dealt two cards from an unlimited deck. Random numbers will represent the cards from 1 to 10. After seeing their hand the user then the computer are given the opportunity to take additional cards. The hand that comes the closest to 21 without exceeding 21 wins the game. A draw results if both players have the same score.
Here is the sample output from the program:
Your Cards: 5 6 = 11
Computers Cards : 4 5 = 9
Do you want another card (y/n)? y
Hit: 5 Your total is 16
Do you want another card (y/n)? y
Hit: 4 Your total is 20
Do you want another card (y/n)? n
The computer takes a card: 9
The computer takes a card: 5
Your score: 20
Computer score: 23
You Won!
To complete this exercises, provide the required code for the following functions: dealCards, hit, and determineWinner.

Yup, that's a prompt alright.Blackjack programming in cC programming blackjack

C++ Poker Program Code

Projects‎ > ‎

C++ Blackjack Example

I created a simple blackjack example using C++ that allows the player to play against a CPU opponent and whoever gets closest to 21 without going over wins. This is a simple blackjack example because players only have the option to hit or stay each turn.

//Specification: This program plays a version of

//the card game of 21.

//A human player is pitted against the computer.

//The player who is the closest to 21 without

//going over wins the hand.

#include

<iostream>

#include

<ctime>

#include

<string>

using

namespace std;

//prototypes...

void

play21(void);

int

dealCards(int, string);

void

hit(int &);

void

determineWinner(int, int);

int

Random(int, int);
void
main(){

char keepPlaying = 'n'; //loop control variable

do {

play21();

//keep playing?

cout <<

'Do you want to play another hand (y/n)?';

cin >> keepPlaying;

}

while(keepPlaying 'Y' keepPlaying 'y');

}

void

play21(void){//play one hand of 21//randomize the cards

srand((

int) time(0));// deal the cardsint person = dealCards(2, 'Your Cards:');

cout <<

' = ' << person << endl;int house = dealCards(2, 'Computers Cards:');

cout <<

' = ' << house << endl;// Ask if human wants a hit

hit(person);

cout << endl;

//Determine if computer takes a hitwhile ((house < person) && (house <= 21) && (person <= 21)) {

house += dealCards(1,

'The Computer takes a card ');

cout << endl;

}

//show who won....

determineWinner(person, house);

}

void

determineWinner(int humanScore, int houseScore) {//compare the scores to see who won//Both the human and the house score totals are provided as arguments//Display total scores and indicate winner//possible outcomes: human wins, computer wins, tie//display the scores

cout <<

'Your Score: ' << humanScore << endl;

cout <<

'Computer Score: ' << houseScore << endl;//decide who should winif (humanScore houseScore)

cout <<

'Tie';if ((humanScore 21 humanScore >= houseScore houseScore > 21) && (humanScore <= 21))

cout <<

'nYou Won!n';else

cout <<

'nThe Computer won!n';

}

int

dealCards(int numberOfCards, string message){//deals cards//The number of cards to be delt is provided as an argument//A message indicating which player is recieving the cards is also//given as an argument //The player message and the cards delt is displayed to the screen//the total value of the cards delt is returnedint cardDealt = 0;int totalValue = 0;

cout << message <<

' ';//deal the number of required cardsfor (int i = 1 ; i <= numberOfCards ; i++){//get a card

cardDealt = Random(1, 10);

//accumulate the card values

totalValue += cardDealt;

cout << cardDealt <<

' ';

}

return totalValue;

}

void

hit(int &playerScore){//Ask the human if they want another card -- 'a hit'//the player's score total is accumulated as they take cards//the player can contiue taking cards until they wish to stop or they exceed 21//After a card is taken the user's current total is displayed//If the user goes over 21 'busted' is displayed//Keep giving the player cards until he wants to stop or goes over 21char takeHit = 'Y';while (takeHit != 'n') {if (playerScore < 21) {//does the player want a hit?

cout <<

'do you want a hit (Y/N)? ';

cin >> takeHit;

if (takeHit 'Y' takeHit 'y'){//the player wants a hit so deal a card

playerScore += dealCards(1,

'Hit: ');

cout <<

'Your total is ' << playerScore << endl;

}

else//the player does not want another card

takeHit =

'n';

}

else {//the player has bustedif (playerScore > 21)

cout <<

'You Busted..nn';

takeHit =

'n';

}

}

}

int

Random(int lowerLimit, int upperLimit) {

//returns a random number within the given boundary

return 1 + rand() % (upperLimit - lowerLimit + 1);

}