Assignment #89
Code
/*
jack newsom
period 5
program BabyBlackjack
filename BabyBlackjack.java
date completed 10/26/15
*/
import java.util.Random;
public class BabyBlackjack
{
public static void main( String[] args )
{
Random r = new Random();
int playerOne = 1 + r.nextInt(10);
int playerTwo = 1 + r.nextInt(10);
int dealerOne = 1 + r.nextInt(10);
int dealerTwo = 1 + r.nextInt(10);
int playerTotal = playerOne + playerTwo;
int dealerTotal = dealerOne + dealerTwo;
System.out.println("Baby Blackjack!");
System.out.println("");
System.out.println("You drew " + playerOne + " and " + playerTwo + ".");
System.out.println("Your total is " + playerTotal + ".");
System.out.println("");
System.out.println("The dealer drew " + dealerOne + " and " + dealerTwo + "." );
System.out.println("The dealer's total is " + dealerTotal );
if ( dealerTotal > playerTotal )
System.out.println("You lose.");
else if ( dealerTotal < playerTotal )
System.out.println("YOU WIN!");
else
System.out.println("Wow. It's a tie.");
}
}
Picture of the output