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

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

import java.util.Scanner; public class Blackjack { public static void main(String [] args) { Scanner scnr = new Scanner(System.in); P1Random rng = new P1Random(); int games = 1; int track = 0; int userInput = 0; int pWins = 0; int dWins = 0; int ties = 0; int hand = 0; int card = 0; boolean exit = true; while (userInput != 4) { if (exit){ card = rng.nextInt(13) + 1; hand = 0; System.out.println("START GAME #" + games); if (card < 11 && card != 1) { //Checks if card is not a face or ace System.out.println("Your card is a " + card + "!"); } else if (card == 11) { System.out.println("Your card is a JACK!"); card = 10; } else if (card == 12) { System.out.println("Your card is a QUEEN!"); card = 10; } else if (card == 13) { System.out.println("Your card is a KING!"); card = 10; } else if (card == 1) { System.out.println("Your card is a ACE!"); } hand = card + hand; System.out.println("Your hand is: " + hand); System.out.println("1. Get another card\n2. Hold hand\n3. Print statistics\n4. Exit"); System.out.println("Choose an option: "); userInput = scnr.nextInt(); exit = false; } while (userInput == 1) { card = rng.nextInt(13) + 1; if (card < 11 && card != 1){ //Checks if card is not a face or ace System.out.println("Your card is a " + card + "!");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture