Project 1 BlackJack.pdf - import java.util.Scanner public...

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

import java.util.Scanner; public class Blackjack { public static void main(String[] args){ P1Random rng = new P1Random(); //initialized various variables int choice; int n = 1; int playerHand; int gamesPlayed = 0; int gameWin = 0; int gameLose = 0; int gameTie = 0; Scanner scanner = new Scanner(System.in); //while loop for each game while (n==1){ System.out.println("\nSTART GAME #" + (gamesPlayed + 1) +"\n"); int playerCard; playerHand = 0; playerCard = rng.nextInt(13) + 1; //gives the first hand, changes king queen and jack to 10 from the randomizer switch(playerCard){ case 13: System.out.println("Your card is a KING!"); playerCard = 10; break; case 12: System.out.println("Your card is a QUEEN!"); playerCard = 10; break;
case 11: System.out.println("Your card is a JACK!"); playerCard = 10; break; case 1: System.out.println("Your card is a ACE!"); break; default: System.out.println("Your card is a " + playerCard + "!"); break; } //player hand function playerHand += playerCard; System.out.println("Your hand is: " + playerHand); //while loop for the in game actions int m = 1; while (m==1) { System.out.println("\n1. Get another card\n2. Hold hand\n3. Print statistics\n4. Exit");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture