Previously in this chapter you saw the card_dealer.py program that simulates cards being dealt
from a deck. Enhance the program so it simulates a simplified version of the game of Blackjack
between two virtual players. The cards have the following values:
Numeric cards are assigned the value they have printed on them. For example, the value of
the 2 of spades is 2, and the value of the 5 of diamonds is 5.
Jacks, queens, and kings are valued at 10.
Aces are valued at 1 or 11, depending on the player’s choice.
The program should deal cards to each player until one player’s hand is worth more than 21
points. When that happens, the other player is the winner. (It is possible that both players’ hands
will simultaneously exceed 21 points, in which case neither player wins.) The program should
repeat until all the cards have been dealt from the deck.
If a player is dealt an ace, the program should decide the value of the card according to the
following rule: The ace will be worth 11 points, unless that makes the player’s hand exceed 21
points. In that case, the ace will be worth 1 point.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- C++: Create a basic contact book where you can store and then retrieve contact information.The information that (at least) should be able to be stored is name (postal) address e-mail address telephone number Birthday, other. It should work as follows. The user should be able to choose what he wants to do, for example : add contact or find the phone number of a given contact. There are several ways to implement this, for example: • To have a menu where the user can choose by entering a number corresponding to one of the menu options. Exit should be one of the options. • where the user gives commands for what to do. The functionality that must exist is • to add a contact, • to delete a contact, • to search for a contact. The contact book should be saved in a file so that it does not disappear between runs of the program.arrow_forwardI need help with creating a Java program described below: Trivia Game Create a simple trivia game for two players. The program will work like this: Starting with player 1, each player gets a turn at answering 5 trivia questions. (There are 10 questions, 5 for each player.) When a question is displayed, four possible answers are also displayed. Only one of the answers is correct, and if the player selects the correct answer, he or she earns a point. After answers have been selected for all of the questions, the program displays the number of points earned by each player and declares the player with the highest number of points the winner. You are to design a Question class to hold the data for a trivia question. The Question class should have String fields for the following data: A trivia question Possible answer 1 Possible answer 2 Possible answer 3 Possible answer 4 The number of the correct answer (1, 2, 3, or 4)…arrow_forwardin Java Tasks Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice yet.) 2. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. (You can use a menu if you prefer.) 3. The computer's choice is displayed. Tasks 4. A winner is selected according to the following rules: a. If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.) b. If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.) C. If one player chooses paper and the other player chooses rock, then paper wins. (Paper wraps…arrow_forward
- Java Programming: Write a command line game that plays a simple version of blackjack. The program should generate random numbers between 1 and 10 each time the player gets a card. It should keep a running total of the players cards, and ask the player whether or not it should deal another card. Sample output for the game is written below. Your program should produce the same output. The players get two cards to start with. Then they are asked if they want more cards. Players can continue to take as many cards as they like. The goal is to get close to 21 without going over. If the total is greater than 21 we say the player "busted".arrow_forwardIn Javaarrow_forwardIn your programming project, you are expected to realize the game of chance called Tombala as a C ++ console application. The details of this game played in real life are listed below: Tombala is a game of chance played over 3 sets with a minimum of 2 and a maximum of 5 players. In the tombala game, each player is given a unique (different) tombala card with 15 integers on it at the start of the game. These whole numbers in question are random numbers in the range of 1 (inclusive) to 90 (inclusive). Each set of the game makes use of a bag of stamps with consecutive integers in the range of 1 (included) to 90 (included). A check is randomly drawn from this bag each time, and each player checks if the number on that checker exists on their tombala card. This process continues similarly until the game set is completed. The player with 5 numbers on his card is deemed to have made the first zinc, the player with 10 numbers drawn from the bag, the second zinc, and the player with all the…arrow_forward
- Java Programming: Write a program that reads five integer values from the user, then analyzes them as if they were a hand of cards. When your program runs it might look like this (user input is in orange for clarity): Enter five numeric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card 3: 8 Card 4: 2 Card 5: 9 Pair! (This is a pair, since there are two eights). You are only required to find the hands Pair and Straight.arrow_forwardWrite a program that plays a dice game called "21" It is a variation on BlackJack where one player plays against the computer trying to get 21 or as close to 21 without going over. Here are the rules of the game: You will play with dice that have numbers from 1 to 11. To win, the player or the computer has to get to 21, or as close as possible without going over. If the player or computer goes over 21, they instantly lose. If there is a tie, the computer wins. Starting the game: The player is asked to give the computer a name. For now, we'll simply call the computer opponent, "computer." The game starts with rolling four dice. The first two dice are for the player. These two dice are added up and the total outputted to the screen. The other two dice are for the computer. Likewise, their total is outputted to the screen. Player: If a total of 21 has been reached by either the player or the computer, the game instantly stops and the winner is declared. Otherwise,…arrow_forwardPlease written by computer source Please solve with C - NIM Gamearrow_forward
- IN C++ Create a task that takes a series of card numbers and checks that their total value is more than 21. If the amount is more than 21, return the truth and if the amount is less than or equal to 21, return false. My card prices are as follows: 2-10 their number. J-K (face cards) are counted as 10. Aces counts as 1 or 11 - play save, so if you give the ace an 11-point make you lose and 1 let you win, then go with 1. Examples overTwentyOne (["2", "8", "J"]) – lie overTwentyOne (["A", "J", "K"]) – - lie overTwentyOne (["5", "5", "3", "9"]) - truearrow_forwardIn your programming project, you are expected to realize the game of chance called Tombala as a C ++ console application. The details of this game played in real life are listed below: Tombala is a game of chance played over 3 sets with a minimum of 2 and a maximum of 5 players. In the tombala game, each player is given a unique (different) tombala card with 15 integers on it at the start of the game. These whole numbers in question are random numbers in the range of 1 (inclusive) to 90 (inclusive). Each set of the game makes use of a bag of stamps with consecutive integers in the range of 1 (included) to 90 (included). A check is randomly drawn from this bag each time, and each player checks if the number on that checker exists on their tombala card. This process continues similarly until the game set is completed. The player with 5 numbers on his card is deemed to have made the first zinc, the player with 10 numbers drawn from the bag, the second zinc, and the…arrow_forwardWrite a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’tdisplay the computer’s choice yet.)2. The user enters his or her choice of “rock,” “paper,” or “scissors” at the keyboard.3. The computer’s choice is displayed.4. A winner is selected according to the following rules:• If one player chooses rock and the other player chooses scissors, then rock wins. (Therock smashes the scissors.)• If one player chooses scissors and the other player chooses paper, then scissors wins.(Scissors cuts paper.)• If one player chooses paper and the other player chooses rock, then paper wins. (Paperwraps rock.)• If both players make the same choice, the game must be…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY