Assignemnt #89 and Baby Blackjack
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Baby Blackjack
///File Name: BabyBlackjack
///Date Finished: 2/9/16
import java.util.Random;
public class BabyBlackjack
{
public static void main( String[] args )
{
Random r = new Random();
int x, cardOne, cardTwo, playerTotal, dealerTotal;
x = 1 + r.nextInt(10);
System.out.println( "Baby Blackjack!" );
cardOne = x;
x = 1 + r.nextInt(10);
cardTwo = x;
playerTotal = cardOne + cardTwo;
x = 1 + r.nextInt(10);
System.out.println(" " );
System.out.println("You drew " + cardOne + " and " + cardTwo + "." );
System.out.println("Your total is " + playerTotal + "." );
System.out.println(" " );
cardOne = x;
x = 1 + r.nextInt(10);
cardTwo = x;
dealerTotal = cardOne + cardTwo;
x = 1 + r.nextInt(10);
System.out.println("The dealer has " + cardOne + " and " + cardTwo + "." );
System.out.println("Dealer's total is " + dealerTotal + "." );
System.out.println(" " );
if( playerTotal > dealerTotal )
{
System.out.println("YOU WIN!" );
}
else if( playerTotal < dealerTotal )
{
System.out.println("YOU LOSE!" );
}
else if( playerTotal == dealerTotal )
{
System.out.println("YOU TIED!" );
}
}
}
Picture of the output