Assignemnt #Project 3 BLACKJACK

Code

 /// Name: JJ Deng
    /// Period: 6
    /// Program Name: BlackJack
    /// File Name: BlackJackP.java
    /// Date Finished: 3/30/2016
    
   import java.util.Random;
import java.util.Scanner;

public class BlackJackP
{
	static final byte PLAYER = 0;
	static final byte DEALER = 1;
	static Random r = new Random();
	static Scanner keyboard = new Scanner(System.in);
	static int playerTotal = 0;
	static int dealerTotal = 0;
	static String read = "";

	public static void main(String[] args)
	{
		setup();

		do
		{
			playerTurn();
		}
		while (!read.equals("stay") && playerTotal < 21);

		if (playerTotal < 22)
		{
			dealerTurn();
		}

		decideWhoWins();
	}

	static void setup()
	{
		System.out.println("Welcome to JJ's blackjack program! ");

		System.out.println("You get a " + newCard(PLAYER) + " and " + newCard(PLAYER) + ".");
		System.out.println("Your Total is "+playerTotal + ".");
		System.out.println();
		System.out.println("The dealer has a " + newCard(DEALER) + " and a hidden card.");
		System.out.println("His total is hidden, too\n");
	}

	static int newCard(byte who)
	{
		int card = r.nextInt(10)+2;

		if (who==PLAYER) playerTotal += card;
		else dealerTotal += card;

		return(card);
	}

	static void playerTurn()
	{
		System.out.print("Would you like to \"hit\" or to \"stay\"? ");
		read = keyboard.nextLine();

		if (!read.equals("stay"))
		{
			if (read.equals("hit"))
			{
				System.out.println("You drew a "+newCard(PLAYER)+".");
				System.out.println("Your total is "+playerTotal + ".\n");
			}
		}
	}

	static void dealerTurn()
	{
		System.out.println("\nOkay, dealer's turn.\n");

		System.out.println("Dealer's hidden card was a " + newCard(DEALER)+".");
		System.out.println("His total is " + dealerTotal + ".\n");

		while(dealerTotal<=16)
		{
			System.out.println("Dealer decides to hit.");
			System.out.println("Dealer draws a "+newCard(DEALER)+".");
			System.out.println("His total is "+dealerTotal + ".\n");
		}
		System.out.println("Dealer decides to stay.\n");
	}

	static void decideWhoWins()
	{
		if (playerTotal>21) System.out.println("HA, NOOB U LOSE");
		else if (dealerTotal>21) System.out.println("WOW, YOU WIN!!!");
		else
		{
			System.out.println("Your total is " + playerTotal + ".");
			System.out.println("Dealer's total is " + dealerTotal + ".\n");

			if (playerTotal > dealerTotal) System.out.println("DAMn BRo U WIN!!!");
			else if (playerTotal < dealerTotal) System.out.println("HA NOOB YOU LOSE!!!");
			else System.out.println("tieā€¦..");
		}
	}
}

    

Picture of the output

Assignment P3