int dealerTotal newCard2 newCard3 if dealerTotal 21 Systemoutprintln

Int dealertotal newcard2 newcard3 if dealertotal 21

This preview shows page 1 - 3 out of 3 pages.

int dealerTotal = newCard[2] + newCard[3]; if (dealerTotal > 21){ System.out.println(); System.out.println("Dealers total is " + dealerTotal + "."); System.out.println("Dealer busts and you win"); System.exit(0); } if (dealerTotal == 21){ System.out.println(); System.out.println("Dealer shows second card: " + newCard[3] + "."); System.out.println("Dealers total is " + dealerTotal + ".");
Image of page 1
System.out.println(); System.out.println("Dealer has BlackJack. you lost"); System.exit(0); } System.out.println("dealer total is hidden."); System.out.println(); // would the player like to hit or stay System.out.print("do you want to \"hit\" or \"stay\"? "); String hitStay = in.next(); System.out.println(); int cc = 4; if (hitStay.equalsIgnoreCase("hit")){ while (playerTotal < 21 && hitStay.equalsIgnoreCase("hit")){ if (hitStay.equalsIgnoreCase("hit")){ System.out.println("You drew a " + newCard[cc] + "."); playerTotal = playerTotal + newCard[cc]; System.out.println("Your total is " + playerTotal + "."); System.out.println(); cc++; //Adds 1 to ensure next card is different. // Bust & Blackjack check. if (playerTotal > 21){ System.out.println("You are bust, You lose."); System.exit(0); } if (playerTotal == 21){ System.out.println("Blackjack, you win."); System.exit(0); } System.out.print("Would you like to \"hit\" or \"stay\"? "); hitStay = in.next(); System.out.println(); } } } // Dealers turn, only if Round 1 didn't end in bust/blackjack. in.close(); System.out.println("Ok dealers turn."); System.out.println("His hidden card was a " + newCard[3] + "."); // reveal hidden from round one.
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 3 pages?

  • Spring '08
  • Kanneko
  • Kurron Lynch

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture