100%(7)7 out of 7 people found this document helpful
This preview shows page 1 - 3 out of 3 pages.
System.out.println("Your card is a QUEEN!");else if(temp == 13)System.out.println("Your card is a KING!");System.out.println("Your hand is: "+playerHand+"\n"); // print to screen when regular cards are dealt.// Print menu to screen for user's options.// Start a new game until user chooses option "4." from the menu.boolean theEnd = false;while(!theEnd){System.out.print("1. Get another card\n2. Hold hand\n3. Print statistics \n 4. Exit \n\n Choose an option: ");choice = sc.nextInt();switch(choice){case 1:
temp = rng.nextInt(13) + 1;playerHand = playerHand +((temp >= 10)? 10 : temp);if(temp == 1)System.out.println("Your card is a ACE!");else if(temp <= 10)System.out.println("Your card is a "+temp+"!");else if(temp == 11)System.out.println("Your card is a JACK!");else if(temp == 12)System.out.println("Your card is a QUEEN!");else if(temp == 13)System.out.println("Your card is a KING!");System.out.println("Your hand is: "+playerHand+"\n"); // Printto screen what the user has been dealt.// Create if / else statements using user's options and cards dealt.if(playerHand == 21) // User wins with 21 points{System.out.println("BLACKJACK! You win!\n");playerWins++;theEnd = true;}else if(playerHand > 21) // user loses if over 21 points are dealt and dealer wins.{System.out.println("You exceeded 21! You lose.\n");dealerWins++;theEnd = true;}break;case 2:temp = rng.nextInt(11) + 16;System.out.println("Dealer's hand: "+temp);System.out.println("Your hand is: "+playerHand+"\n");if(temp > 21){System.out.println("You win!\n");playerWins++;theEnd = true;}else if(temp == playerHand){System.out.println("It's a tie! No one wins!\n");