Question: My code keeps on only dealing me a card number 0. Please help so that my code deals different numbers import java.util.*; public class Blackjack

 My code keeps on only dealing me a card number 0.Please help so that my code deals different numbers import java.util.*; publicclass Blackjack { public static void main(String args[]) { Scanner scanner =

My code keeps on only dealing me a card number 0. Please help so that my code deals different numbers

import java.util.*; public class Blackjack { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int round = 0; double round1 = 0; int card = 0; int option = 1; int playerwins = 0; double playerwins1 = 0; int dealerwins = 0; int dealer = 0; int tiegames = 0; double tiegames1 = 0; do { round = round + 1; round1 = round1 + 1; int win = 0; System.out.println("START GAME #" + round + " "); option = 1; int hand = 0; dealer = 0; do { if (option == 1) { if (card == 1) { System.out.println("Your card is a ACE!"); } else if (card == 11) { card = 10; System.out.println("Your card is a JACK!"); } else if (card == 12) { card = 10; System.out.println("Your card is a QUEEN!"); } else if (card == 13) { card = 10; System.out.println("Your card is a KING!"); } else { System.out.println("Your card is a " + card + "!"); } hand = card + hand; System.out.println("Your hand is: " + hand); if (hand > 21) { System.out.println(" You exceeded 21! You lose. "); dealerwins = dealerwins + 1; break; } else if (hand == 21) { System.out.println(" BLACKJACK! You win! "); playerwins = playerwins + 1; playerwins1 = playerwins1 + 1; break; } System.out.println(" 1. Get another card"); System.out.println("2. Hold hand"); System.out.println("3. Print statistics"); System.out.println("4. Exit"); System.out.print(" Choose an option: "); option = scanner.nextInt(); System.out.print(" "); } else if (option == 2) { System.out.println("Dealer's hand: " + dealer); System.out.println("Your hand is: " + hand + " "); if (hand > dealer && hand  hand && dealer  21) { System.out.println("You win! "); win = 1; playerwins = playerwins + 1; playerwins1 = playerwins1 + 1; } else if (hand == dealer) { System.out.println("It's a tie! No one wins! "); tiegames = tiegames + 1; tiegames1 = tiegames1 + 1; win = 1; } } else if (option == 3) { double percent = ((playerwins1) / (round1 - 1)) * 100; int games = round - 1; System.out.println("Number of Player wins: " + playerwins); System.out.println("Number of Dealer wins: " + dealerwins); System.out.println("Number of tie games: " + tiegames); System.out.println("Total # of games played is: " + games); System.out.println("Percentage of Player wins: " + percent + "%"); System.out.println(" 1. Get another card"); System.out.println("2. Hold hand"); System.out.println("3. Print statistics"); System.out.println("4. Exit"); System.out.print(" Choose an option: "); option = scanner.nextInt(); System.out.print(""); } else if (option == 4) { break; } else { System.out.println("Invalid input! Please enter an integer value between 1 and 4."); System.out.println(" 1. Get another card"); System.out.println("2. Hold hand"); System.out.println("3. Print statistics"); System.out.println("4. Exit"); System.out.print(" Choose an option: "); option = scanner.nextInt(); System.out.print(" "); while (option > 4 || option   Overview In this project students will simulate a simplified version of the game Blackjack. Students will implement random card drawing, calculation, state tracking, and console input systems. The project is designed to be a playful yet practical opportunity to practice data types, console I/O, control structures, and libraries. Rules of the Road Forewarning: this specification does NOT follow the rules of casino Blackjack. Don't drop out of your studies and move to Vegas just because you can beat your own randomized AI! A typical game will play out as follows: The player will be dealt one card at the start of the game (where a game is one round of play). The player, based on the value of his cards, can either ask for another card (a hit) or choose to hold (stand). The dealer will then begin his turn and try to beat the player's hand. The player is competing against the dealer, who has his own hand. Whomever is closer to 21 at the end of the game (as long as they don't exceed 21) wins the game. 1. Player's turn: Player tries to reach or come close to 21 without going over (as 21 is the highest hand). 2. Dealer's turn: Dealer tries to beat exceed the player's hand without going over 21. 3. Determine the winner at the end of the game and increment the win count. 4. Repeat! You will need a while loop in your program. The loop will allow you to play successive games without restarting the program each time; it will also allow you to keep a win count over multiple games. Here is the basic syntax of a while loop: while (boolean_expression) while (boolean expression) { // Statements } Statements If the boolean expression evaluates to true, the loop continues. If/when it ever evaluates to false, then the loop terminates (we skip over the loop block) and continue with the program. Here is an example of a while loop: int x= 0; while (x 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!