Assignment #89 and Baby Blackjack
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Baby Blackjack
/// File Name: BabyBlackjack.java
/// Date Finished: 10/30/2015
import java.util.Random;
public class BabyBlackjack
{
public static void main( String[] args )
{
Random r = new Random();
int playerCard1 = 1 + r.nextInt(10);
int playerCard2 = 1 + r.nextInt(10);
int dealerCard1 = 1 + r.nextInt(10);
int dealerCard2 = 1 + r.nextInt(10);
int playerTotal = playerCard1 + playerCard2;
int dealerTotal = dealerCard1 + dealerCard2;
System.out.println( "Baby Blackjack!\n" );
System.out.println( "You drew " + playerCard1 + " and " + playerCard2 + "." );
System.out.println( "Your total is " + playerTotal + ".\n" );
System.out.println( "The dealer has " + dealerCard1 + " and " + dealerCard2 + "." );
System.out.println( "Dealer's total is " + dealerTotal + ".\n" );
if ( playerTotal > dealerTotal )
System.out.println( "YOU WIN!" );
else if ( playerTotal < dealerTotal )
System.out.println( "YOU LOSE:(" );
else
System.out.println( "It's a tie!" );
}
}
Picture of the output