Write a Java program to simulate a blackjack game of cards. The computer will play the role of the dealer. The program will randomly generate the cards dealt to the player and dealer during the game. Cards in this game will be represented by numbers 1 to 13 with Ace being represented by a 1. Remember, that face cards (i.e. Jack, Queen, and King) are worth 10 points to a hand while an Ace can be worth 1 or 11 points depending on the user’s choice. The numbered cards are worth their number value to the hand. Here are the details of how to play the game: To start the game, the player is given two randomly chosen cards and told their values. The dealer is then given two cards randomly. The human player should only be told the value of the first card given to the dealer. The other card in the dealer's hand is "hidden" until the end of the game. The player is then asked if they want to draw another card for their hand. While the player wishes to draw another card and neither hand has gone over 21, the game will continue. If the player wishes to draw, a new card value is drawn and added to the player's hand. Assume the dealer will take a card each time the player does until the dealer or player goes bust (i.e. goes over 21 points in their hand) or the player stops the game by saying they no longer want to take another card. Once the player stops wanting to draw a card, the game ends and the result is told to the user. Remember, the game also ends when either the player or dealer goes over 21. (See additional game rules below.) Each time the user draws a card they should be told what value card they drew and their resulting hand value. Each time the dealer draws a card the human player should be told the new card value that was drawn by the dealer, but not the dealer's hand total. Remember, one of the dealer's cards is hidden from the player. Card values for the player and computer will be chosen at random and range between 1 and 13 (both values inclusive). If a 1 (i.e. Ace) is chosen for a card value for the human player, the player gets to choose which value either a 1 or 11 they want to add to their hand. Note: The computer just gets the 1 or 11 chosen for them randomly instead of getting a choice. To win the game, the player must get higher than the computer’s hand without going over 21. The player automatically loses if their hand goes over 21. The game ends and the player wins if the dealer's hand goes over 21 at the draw of a new card by the dealer. The player loses if their hand is less than the dealer’s hand once the player chooses to stop drawing cards. The player Page 2 of 3 can tie with the dealer. The player wins if their hand is greater than the dealer’s hand once the player chooses to stop drawing cards. Be sure to provide appropriate output the player when the game is over before presenting the player with the option to play again. Provide the following menu using a do..while loop in the main method to the user. 1. Play Again 2. Exit Your program must have 2 additional methods at a minimum: 1. You must use a method to draw the cards (i.e. generate the card values as drawn). 2. You must use a method to determine the winner of the game after game play ends. Additional Assignment Requirements 1. You MUST use While loops in each method in this assignment. 2. You may NOT use an array to store the cards in each hand. 3. You may NOT use Java libraries or programming concepts not yet learned in this course. This assignment is designed to assess that you understand the concepts being presented in the course this week, not concepts we will learn at a later time. 4. You may NOT discuss this problem with your classmates. This assignment is independent work. Work copied from another student or an online resource will result in enforcement of EKU’s Academic Integrity policy as discussed in the syllabus. 5. You must use appropriate spacing, indention, naming conventions, and documentation in your Java program. 6. You will upload your completed work by attaching your HW6FirstnameLastname.java to your submission in Blackboard for the lab assignment.
Write a Java program to simulate a blackjack game of cards. The computer will play the role of the dealer. The program will randomly generate the cards dealt to the player and dealer during the game. Cards in this game will be represented by numbers 1 to 13 with Ace being represented by a 1. Remember, that face cards (i.e. Jack, Queen, and King) are worth 10 points to a hand while an Ace can be worth 1 or 11 points depending on the user’s choice. The numbered cards are worth their number value to the hand. Here are the details of how to play the game: To start the game, the player is given two randomly chosen cards and told their values. The dealer is then given two cards randomly. The human player should only be told the value of the first card given to the dealer. The other card in the dealer's hand is "hidden" until the end of the game. The player is then asked if they want to draw another card for their hand. While the player wishes to draw another card and neither hand has gone over 21, the game will continue. If the player wishes to draw, a new card value is drawn and added to the player's hand. Assume the dealer will take a card each time the player does until the dealer or player goes bust (i.e. goes over 21 points in their hand) or the player stops the game by saying they no longer want to take another card. Once the player stops wanting to draw a card, the game ends and the result is told to the user. Remember, the game also ends when either the player or dealer goes over 21. (See additional game rules below.) Each time the user draws a card they should be told what value card they drew and their resulting hand value. Each time the dealer draws a card the human player should be told the new card value that was drawn by the dealer, but not the dealer's hand total. Remember, one of the dealer's cards is hidden from the player. Card values for the player and computer will be chosen at random and range between 1 and 13 (both values inclusive). If a 1 (i.e. Ace) is chosen for a card value for the human player, the player gets to choose which value either a 1 or 11 they want to add to their hand. Note: The computer just gets the 1 or 11 chosen for them randomly instead of getting a choice. To win the game, the player must get higher than the computer’s hand without going over 21. The player automatically loses if their hand goes over 21. The game ends and the player wins if the dealer's hand goes over 21 at the draw of a new card by the dealer. The player loses if their hand is less than the dealer’s hand once the player chooses to stop drawing cards. The player Page 2 of 3 can tie with the dealer. The player wins if their hand is greater than the dealer’s hand once the player chooses to stop drawing cards. Be sure to provide appropriate output the player when the game is over before presenting the player with the option to play again. Provide the following menu using a do..while loop in the main method to the user. 1. Play Again 2. Exit Your program must have 2 additional methods at a minimum: 1. You must use a method to draw the cards (i.e. generate the card values as drawn). 2. You must use a method to determine the winner of the game after game play ends. Additional Assignment Requirements 1. You MUST use While loops in each method in this assignment. 2. You may NOT use an array to store the cards in each hand. 3. You may NOT use Java libraries or
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 9 images