Blackjack.java - Cited how to format from...

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

// Cited how to format from ** - format-decimal-number-in-java.html ** import java.text.DecimalFormat; // formats the decimal integers properly import java.util.Scanner; // Scanner allows user's input public class Blackjack { public static void main(String args[]) { // Create an array for the regular numbered cards dealt to the user. int choice = 0,i = 0,playerWins = 0,dealerWins = 0,tie = 0; Scanner sc = new Scanner(System.in); P1Random rng = new P1Random(); while(choice != 4) { int playerHand = 0,temp; System.out.println("START GAME #"+(++i)+"\n"); // Cards need to be dealt. // If variables/face cards have the value of 10 or more, give the value of 10 these cards when dealt. temp = rng.nextInt(13) + 1; playerHand = (temp >= 10)? 10 : temp; // Print on screen the results of the cards dealt for the user playing Blackjack game. // Assign variables for each face card. 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!");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture