Question: Help with C programming: Write a program to let the user play a game called Blackjack Dice against the dealer. The game is played with
Help with C programming:
Write a program to let the user play a game called Blackjack Dice against the dealer. The game is played with two, 11- sided dice, where each die has faces representing the numbers 1 through 11. The objective of the game is to roll 21. If the user or the dealer goes over 21, it is considered a bust and a loss. In general, the players score must beat the dealers or the player loses.
How the game is played: The player begins by rolling 2 dice and the players total is the sum rolled on the two dice. If the players total is 21 on the first roll that is considered blackjack and the player automatically wins. If the player does not roll 21 on the first roll, they may choose to roll a single die as many times as they wish, adding the value of the resulting roll to their total. If the players total exceeds 21, they bust and lose the game. After the player is done rolling and if the player did not get blackjack, the dealer begins by rolling the 2 dice and the dealers total is the sum rolled on the two dice. If the dealer gets a total of 21 on the first roll, that is blackjack and the dealer wins. If the total is greater than 16, the dealer stops rolling. Otherwise, the dealer continues to roll a single die with the value of each roll added to total until his total is greater than 16. If the dealer busts by going over 21, the player wins. The dealer wins all ties. Your program must consist of at least four functions: main( ), rollDie( ), playersTurn( ), and dealersTurn( ). The function rollDie( ) simulates the rolling of an 11-sided die. The function playersTurn( ) implements the players turn. The function dealersTurn( ) implements the dealers turn. Sample output from a program that satisfies the requirements of this exercise is given below.
Example 1:
****** PLAYER'S TURN ****** Roll: 10 11 Total: 21 Blackjack! ****** GAME SUMMARY ****** Player wins!
Example 2:
****** PLAYER'S TURN ****** Roll: 10 8 Total: 18 Enter R to Roll or S to Stay: S ****** DEALER'S TURN ****** Roll: 7 6 Total: 13 Roll: 5 Total: 18 ****** GAME SUMMARY ****** Dealer wins!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
