Assignment #89 Baby Blackjack
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Baby Blackjack
/// File Name: BabyBlackjack.java
/// Date Finished: 2/19/2016
import java.util.Random;
public class BabyBlackjack
{
public static void main( String[] args )
{
Random r = new Random();
int uhand1, uhand2, dhand1, dhand2, utotal, dtotal;
uhand1 = 1 + r.nextInt(10);
uhand2 = 1 + r.nextInt(10);
dhand1 = 1 + r.nextInt(10);
dhand2 = 1 + r.nextInt(10);
utotal = uhand1 + uhand2;
dtotal = dhand1 + dhand2;
System.out.println();
System.out.println( "Baby Blackjack!" );
System.out.println();
System.out.println( "You drew " + uhand1 + " and " + uhand2 + "." );
System.out.println( "Your total is " + utotal + "." );
System.out.println();
System.out.println( "The dealer has " + dhand1 + " and " + dhand2 + "." );
System.out.println( "Dealer's total is " + dtotal + "." );
System.out.println();
if ( utotal > dtotal )
{
System.out.println( "You win" );
}
if ( dtotal > utotal )
{
System.out.println( "You lose" );
}
if ( dtotal == utotal )
{
System.out.println( "You tied" );
}
}
}
Picture of the output