Blackjack.java - import java.util.Scanner public class...

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

import java.util.Scanner; public class Blackjack { //the following function is used to translate the card's numerical values to their face values. public static String intToCardValue(int input) { String output = ""; if (input == 1) { output = "ACE"; } else if (input > 1 && input < 11) { output = String.valueOf(input); } else if (input == 11) { output = "JACK"; } else if (input == 12) { output = "QUEEN"; } else if (input == 13) { output = "KING"; } return output; } public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //these intergers keep track of the game's stats. int gamesPlayed = 0; int numWins = 0; int dealerWins = 0; int numTies = 0; /*these booleans are in charge of the two loops that make up the program. newGame is the outer loop that starts a new game after a game is completed. gameRunning is the nested loop that loops while within a current game until a result is a achieved. */ boolean newGame = true; boolean gameRunning; //these intergers deal with the card dealing process. P1Random rng = new P1Random(); int myNumber; int menuSelect; int playerHand=0; int dealerHand=0; /* while-loop 'newGame' is the outer loop that starts a new game after a game is completed.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture