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 { //This project is a simplified version of the game Blackjack public static void main(String[] args) { Scanner input = new Scanner(System.in); //For Inputs (Menu Choice) P1Random rng = new P1Random(); //For Random Numbers //Declare Variables int gameNumber = 0; int myNumber; int myHand; int dealerHand; int dealerWins = 0; int playerWins = 0; int tieGames = 0; double percentageWins; int choice = 0; //Start the game while (choice != 4) { myHand = 0; gameNumber++; System.out.println("START GAME #" + gameNumber + "\n"); while (myHand >= 0 ) { //Get a card if(myHand == 0 || choice == 1) { myNumber = rng.nextInt(13) + 1; switch (myNumber) { //Calculate the value of the player's cards following the case case 1: System.out.println("Your card is a ACE!"); myHand += 1; break; case 2: System.out.println("Your card is a 2!"); myHand += 2; break; case 3: System.out.println("Your card is a 3!"); myHand += 3; break; case 4: System.out.println("Your card is a 4!"); myHand += 4; break; case 5: System.out.println("Your card is a 5!"); myHand += 5; break; case 6: System.out.println("Your card is a 6!"); myHand += 6; break;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture